与Cisco路由器的永久SSH会话

与Cisco路由器的永久SSH会话,第1张

与Cisco路由器的永久SSH会话

我使用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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5668695.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存