Paramiko SSHClient.connect() problem

Chris Angelico rosuav at gmail.com
Tue Oct 27 14:40:30 EDT 2015


On Wed, Oct 28, 2015 at 12:23 AM, Skip Montanaro
<skip.montanaro at gmail.com> wrote:
> 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.

The "bad family" error suggests that there's a mismatch between IPv4
and IPv6. It's common for /etc/hosts to contain two references to
localhost, one as 127.0.0.1 and another as ::1 (IPv4 and IPv6
respectively), and if ssh.connect() is picking the wrong one, it'll
have trouble. If you hack your hosts file to have only one localhost,
does the problem disappear?

ChrisA



More information about the Python-list mailing list