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
If it's private network try adding line ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
after creation of SSHClient
.
AutoAddPolicy from Paramiko docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With