How do I ssh to a server that requires dual password authentication using Paramiko?
When using a particular user, it first prompts for the user password and then fo
Your server uses a standard password authentication for the first password.
The second password is asked only once shell is starting. Simple I/O is used for that.
Additionally, your server does not seem to support "exec" interface/channel to execute commands (as ssh user@host command
does not work). What is probably related to the "shell password" feature. So you probably have to use "shell" channel to execute your command, what is otherwise not recommended.
ssh = paramiko.SSHClient()
ssh.connect(hostname, username = username, password = password1)
channel = ssh.invoke_shell()
channel.send(password2 + "\n")
channel.send(command + "\n")
while not channel.recv_ready():
time.sleep(1)
out = channel.recv(9999)