我有一个简单的脚本,可以通过SSH连接到诺基亚路由器并执行"show time"命令:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('adres ip', port=22, username='username', password='password')
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('show time')
output = stdout.readlines()
print '\n'.join(output)
ssh.close()
节点登录成功。我可以在路由器上看到自己,但是执行命令是不可行的。我会收到以下错误信息:
Traceback (most recent call last): File "C:\Users\pkudalsk\Desktop\pyt.py", line 6, in <module>
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('show time') File "C:\Users\pkudalsk\Desktop\paramiko\client.py", line 479, in exec_command
chan.exec_command(command) File "C:\Users\pkudalsk\Desktop\paramiko\channel.py", line 63, in _check
return func(self, *args, **kwds) File "C:\Users\pkudalsk\Desktop\paramiko\channel.py", line 241, in exec_comman d
self._wait_for_event() File "C:\Users\pkudalsk\Desktop\paramiko\channel.py", line 1198, in
_wait_for_ event
raise e EOFError
有人知道是什么原因导致这个问题吗?我已经尝试使用Python 3.6和2.7,结果相同。
谢谢