Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kinit from Python script using keytab

Does anyone know how to kinit from within a python script using keytab; that is to avoid having to prompt for a password?

like image 871
sdfasdfasdf Avatar asked Oct 29 '25 04:10

sdfasdfasdf


2 Answers

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
like image 139
Bruno Wego Avatar answered Oct 31 '25 19:10

Bruno Wego


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()
like image 44
interestedparty333 Avatar answered Oct 31 '25 18:10

interestedparty333



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!