Python Paramiko (Client) Multifactor Authentication

前端 未结 2 781
Happy的楠姐
Happy的楠姐 2021-01-06 03:14

I\'m attempting to use Paramiko (on Python 2.7) to connect to a host that uses multifactor authentication (username + password + one-time-password). The transport.auth

2条回答
  •  温柔的废话
    2021-01-06 03:32

    A more convenient way is the auth_interactive_dumb method. it is an auth_interactive that just outputs what the server asks to the console and sends back what you type. This way you dont have to store the password and dont have to write your own handler.

    so basically

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(("mfahost.example.com", 22))
    ts = paramiko.Transport(sock)
    ts.start_client(timeout=10)
    ts.auth_interactive_dumb(user)
    

提交回复
热议问题