Trouble connecting via paramiko + kerberos

2019-05-10 23:44发布

问题:

Currently when I want to connect to a node I simply do: ssh username@node and everything works fine. (thanks Kerberos :-)) Now I'm trying to develop a simple python script that connect to a specified host but I cannot connect to it using that script.
The following my script:

import paramiko
import gssapi

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect(hostname = 'node_name', username = 'my_uname', gss_auth = True, gss_kex = True)

But I received this error:

paramiko.ssh_exception.AuthenticationException: Authentication failed.

I tried also

ssh.connect(hostname = 'node_name', username = 'my_uname', gss_auth = True, gss_kex = True, gss_deleg_creds=True)

and the error I received changed a bit:

gssapi.error.GSSException: (131072) An invalid name was supplied. Minor code: (100001) Success. Target: node_name

Any suggestions? Thanks!