Paramiko SSHClient.connect() problem

Skip Montanaro skip.montanaro at gmail.com
Tue Oct 27 09:23:21 EDT 2015


I'm trying to use paramiko (for the first time) to connect to both the
localhost and a remote host as I read along in Jesse Noller's blog post
<http://jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different>.
That host is listed in ~/.ssh/known_hosts three different ways: unqualified
hostname, fully qualified hostname, partially qualified hostname, and IP
address. In all cases, it raises an SSHException. Here's an attempt to
connect to localhost:

>>> import paramiko
>>> ssh = paramiko.SSHClient()
>>> conn = ssh.connect("127.0.0.1")
SSHException Server '127.0.0.1' not found in known_hosts
[<stdin>|<module>|1] [paramiko/client.py|connect|288]
[paramiko/client.py|missing_host_key|570]

I'm using paramiko 1.15.2 on an OpenSuSE 12.2 system. It's true that
"127.0.0.1" doesn't appear in known_hosts, but the remote host I care about
does, and it gets the same result:

>>> ssh = paramiko.SSHClient()
>>> conn = ssh.connect("firefly")
SSHException Server 'firefly' not found in known_hosts
[<stdin>|<module>|1] [paramiko/client.py|connect|288]
[paramiko/client.py|missing_host_key|570]

Finally, there is also a "localhost" record in known_hosts. Connecting to
that fails with a different exception:

>>> ssh = paramiko.SSHClient()
>>> conn = ssh.connect("localhost")
error getsockaddrarg: bad family
[<stdin>|<module>|1] [paramiko/client.py|connect|251]
[paramiko/util.py|retry_on_signal|270] [paramiko/client.py|<lambda>|251]
[/opt/TWWfsw/python27/lib/python2.7/socket.py|meth|224]

I use host key authentication, not password authentication.

Any pointers appreciated.

Skip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151027/5c1225b7/attachment.html>


More information about the Python-list mailing list