【问题标题】:kinit from python script using keytab使用 keytab 从 python 脚本启动 kinit
【发布时间】:2011-08-25 21:39:05
【问题描述】:

有谁知道如何在 python 脚本中使用 keytab 进行 kinit?那是为了避免提示输入密码?

谢谢

【问题讨论】:

    标签: python subprocess popen


    【解决方案1】:

    我更喜欢使用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
    

    【讨论】:

    • krbcontext 完美地包装了 gssapi,我永远无法弄清楚如何使用 gssapi 来验证密钥表。谢谢!
    【解决方案2】:
    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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-17
      • 2014-09-14
      相关资源
      最近更新 更多