Paramiko/Python: Keyboard interactive authentication

后端 未结 1 830
抹茶落季
抹茶落季 2020-12-01 22:52

I\'m having a hard time trying to create an SFTP client using Paramiko (Python).

Code:

 import paramiko as sftp

 transport = sftp.Transport((\'myho         


        
相关标签:
1条回答
  • 2020-12-01 23:41

    Your server is using a keyboard-interactive authentication, not a simple password authentication.

    Normally Paramiko is smart enough to fallback to the keyboard-interactive authentication, when the password authentication fails and the keyboard-interactive prompt has one field only (likely a password).

    The problem is that your server behaves, as if the password authentication succeeded.

    You can explicitly make Paramiko try the keyboard-interactive authentication using this code:

    def handler(title, instructions, fields):
        if len(fields) > 1:
            raise SSHException("Expecting one field only.")
        return [password]
    
    transport = paramiko.Transport('example.com') 
    transport.connect(username='myuser')
    transport.auth_interactive(username, handler)
    
    0 讨论(0)
提交回复
热议问题