4

I want to send a command over ssh with python

from paramiko import SSHClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect("192.168.0.62",port="22", username="username", password="password") 

And when i run it I get this

 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 

What should i do

1
  • your known host key is missing in host keys file ... add the key in file or change the mode to ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) this is not a good way during security concerns. Commented Oct 12, 2019 at 21:29

1 Answer 1

4

If it's private network try adding line ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) after creation of SSHClient.

AutoAddPolicy from Paramiko docs

Sign up to request clarification or add additional context in comments.

Comments