5

我只有这样的简单脚本,通过诺基亚路由器上的 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 上试过。同样的结果。

谢谢

4

0 回答 0