我想为测试ssh连接运行简单命令。有关stdin / out / err的错误。代码和错误消息如下所示。
有人可以帮助我吗?
import paramiko
import sys
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('x.x.x.x', port=2222, username='user', password='pass')
stdin, stdout, stderr = client.exec_command('exit')
print stdout
client.close()
Traceback (most recent call last):
File "C:/Users/EXT03D3912/PycharmProjects/paramiko_ssh1/paramiko_ssh1.py", line 9, in <module>
stdin, stdout, stderr = client.exec_command('exit')
File "build\bdist.win32\egg\paramiko\client.py", line 343, in exec_command
File "build\bdist.win32\egg\paramiko\channel.py", line 212, in exec_command
File "build\bdist.win32\egg\paramiko\channel.py", line 1081, in _wait_for_event
EOFError
感谢, haktan
答案 0 :(得分:0)
由于你从终端登出,它正在提供EOFError AFAIK,你可以关闭连接,它会自动关闭你的会话。
考虑以下代码
{{1}}