我想使用python通过ssh发送命令
from paramiko import SSHClient
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect("192.168.0.62",port="22", username="username", password="password")
当我运行它时,我得到了
File "prog.py", line 8, in <module>
ssh.connect("192.168.0.62",port="22", username="username", password="password")
File "/home/rick/.local/lib/python2.7/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/home/rick/.local/lib/python2.7/site-packages/paramiko/client.py", line 824, in missing_host_key
"Server {!r} not found in known_hosts".format(hostname)
paramiko.ssh_exception.SSHException: Server '[192.168.0.62]:22' not found in known_hosts
我该怎么办
答案 0 :(得分:0)
如果是专用网络,请尝试添加第ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
行
创建SSHClient
之后。
AutoAddPolicy来自Paramiko文档