开发者

kinit from Python script using keytab

开发者 https://www.devze.com 2023-03-31 08:38 出处:网络
Does anyone know how to kinit from within a python script usi开发者_如何学Pythonng keytab; that is to avoid having to prompt for a password?I prefer use libraries such as krbcontext:

Does anyone know how to kinit from within a python script usi开发者_如何学Pythonng keytab; that is to avoid having to prompt for a password?


I prefer use libraries such as krbcontext:

from krbcontext.context import krbContext

with krbContext(using_keytab=True, principal='[username]@[REALM]', keytab_file='/etc/security/keytabs/[name].keytab', ccache_file='/tmp/krb5cc_pid_appname'):
    pass


from subprocess import Popen, PIPE

kinit_args - [ '/usr/bin/kinit', '-kt', '/home/username/username.keytab', 'username@realm' ]
subp = Popen(kinit_args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
subp.wait()
0

精彩评论

暂无评论...
验证码 换一张
取 消