python – Paramiko does not work when grequests is loaded-ThrowExceptions

Exception or error:

In python CLI, I run those script, then got error:

import grequests
import paramiko

client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=remote_host,
                                port=22,
                                username=username,
                                password=password)
File "<stdin>", line 4, in <module>
  File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 406, in connect
    t.start_client(timeout=timeout)
  File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 660, in start_client
    raise e

Python 2.7.15+
paramiko (2.7.1)
grequests (0.4.0)

After add those 2 lines after import paramiko, I got a new error

from gevent import monkey
monkey.patch_all()
/usr/lib/python2.7/site-packages/paramiko/client.py", line 423, in connect
    raise BadHostKeyException(hostname, server_key, our_key)
paramiko.ssh_exception.BadHostKeyException: Host key for server '*' does not match:
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *