我正在尝试建立 SSH 连接并使用 paramiko 执行命令的最简单方法
import paramiko, base64
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('10.50.0.150', username='XXXXX', password='XXXXXX')
stdin, stdout, stderr = client.exec_command('show performance -type host-io')
for line in stdout:
print '... ' + line.strip('\n')
client.close()
- - - - - - 错误 - - - - - - - - - - - -
Traceback (most recent call last):
File "a.py", line 5, in <module>
stdin, stdout, stderr = client.exec_command('show performance -type host-io')
File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/client.py", line 374, in exec_command
chan.exec_command(command)
File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/channel.py", line 218, in exec_command
self._wait_for_event()
File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/channel.py", line 1122, in _wait_for_event
raise e
EOFError
如果我执行此代码将其工作的命令更改为另一台计算机,则此命令可以通过 SSH 交互 shell 正常工作。
任何想法 ?