views:

185

answers:

1

I'm trying to automate a ssh connection and control of a network device, that for some reason, only allows keyboard-interactive authentication. It doesn't appear that paramiko supports this by default or with the standard sshclient() object.

I've spent the past couple of days going through the paramiko documentation trying to figure this out, and this is the closest that I've been able to get working.

import paramiko
import socket

def ihandler(title,instructions,prompt_list):
  return 'pass'


if __name__=="__main__":
  paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
  s=socket.socket()
  s.connect(('localhost',22))
  t=paramiko.Transport(s)
  t.set_log_channel("paramiko.transport")
  t.start_client()
  t.auth_password('user','pass')
  t.auth_interactive ('user',ihandler)

Any help would be greatly appreciated.

A: 

What you want is pxssh from the pxpect project. Look at the sshls.py and ssh_tunnel.py examples.

http://www.noah.org/wiki/Pexpect

snies