我正在使用 pepexpect 登录路由器。我这样做的方法是登录到 linux 服务器,然后登录到路由器。
usr = 'myusername'
pwd='mypwd'
child.sendline('ssh -o StrictHostKeyChecking=no -l '+usr+' '+ip)
index = child.expect(['assword:', pexpect.EOF,pexpect.TIMEOUT])
当我手动登录路由器时,我得到以下信息:
WARNING NOTICE: This is a private system. The actual or attempted, unauthorized
access, use or modification of this system is strictly prohibited.
Individuals undertaking such unauthorized access, use or modification are
subject to company disciplinary proceedings and/or criminal and civil penalties
under applicable domestic and foreign laws. The use of this system may be
monitored and recorded for administrative and security reasons in accordance
with local law. If such monitoring and/or recording reveals possible evidence
of criminal activity, the results of such monitoring may be provided to law
enforcement officials. Continued use of this system after receipt of this
notice constitutes consent to such security monitoring and recording.
!
Global Baseline Configuration: v1.0
Cisco Wide Area Application Engine
username@10.58.218.237's password:
即使密码在输出上,索引结果也是 2 = pexpect.TIMEOUT 我的脚本在其他路由器上工作,但我不知道为什么不在这个路由器上工作。谢谢