我使用Exscript而不是paramiko,现在可以在IOS设备上进行持久会话。
#!/opt/local/bin/pythonimport hashlibimport Exscriptfrom Exscript.util.interact import read_loginfrom Exscript.protocols import SSH2account = read_login() # prompt the user for his name and passwordconn = SSH2() # We choose to use SSH2conn.connect('192.168.221.235') # Open the SSH connectionconn.login(account) # Authenticate on the remote hostconn.execute('conf t') # Execute the "uname -a" commandconn.execute('interface Serial1/0')conn.execute('ip address 114.168.221.202 255.255.255.0')conn.execute('no shutdown')conn.execute('end')conn.execute('sh run int Serial1/0')print conn.responseconn.execute('show ip route')print conn.responseconn.send('exitr') # Send the "exit" commandconn.close() # Wait for the connection to close
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)