SSHClient.connect fails on Windows XP

Bug #411910 reported by Andrew Wilkins
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
paramiko
Fix Committed
High
Robey Pointer

Bug Description

I have just upgraded to Paramiko 1.7.5 (Ernest), and tested it on a Windows XP host. Attempting to call SSHClient.connect fails with the following exception:
   paramiko.SSHException: No suitable address family for titan

This bug appears to have been introduced with the new IPv6 support. Calling getaddrinfo may yield results with socktype=0, which are silently ignored by Paramiko. If you specify a hint of socket.SOCK_STREAM, the resulting socktype should be socket.SOCK_STREAM. i.e.
   socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM)

Revision history for this message
Alexandre Depriester (alexandre-depriester) wrote :

Hi,

I had the same problem under Windows XP and i solved it with your guidance.
This is my patch for client.py.

$ diff -u client.py.old client.py
--- client.py.old 2009-08-11 16:32:32.000000000 +0200
+++ client.py 2009-08-11 16:23:10.000000000 +0200
@@ -274,7 +274,7 @@
         @raise socket.error: if a socket error occurred while connecting
         """
         for (family, socktype, proto, canonname, sockaddr) in \
- socket.getaddrinfo(hostname, port):
+ socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM
):
             if socktype==socket.SOCK_STREAM:
                 af = family
                 addr = sockaddr

Revision history for this message
Joe Python (jopython) wrote :

Thank you for the solution. It works for me.
Hope they add this change to the code.

Revision history for this message
jumpfroggy (virtue) wrote :

I just ran into this myself, just wanted to confirm that Alexandre's patch fixed my problem as well. Windows XP, Python 2.5.4, Paramiko 1.7.5. Thanks!

Revision history for this message
yakaneli (jenglund) wrote :

Hi, I am having the same problem as well, and am also fairly new to python, so I must ask a stupid question. How to I apply that patch file to client.py in my paramiko library? Thanks

Revision history for this message
vishnu (vishnu1986) wrote :

Hi, I too do not know where to apply the patch client.py in the paramiko library. Any information regarding teh same would help me. Thank you.

Revision history for this message
yakaneli (jenglund) wrote : Re: [Bug 411910] Re: SSHClient.connect fails on Windows XP

Hey, I just looked at the file client.py and then did the changes myself
manually...and then it worked great. It only makes a change to one line, I
was able to figure it out pretty easily.

"patch" is a unix command and I was using windows anyway

Hope this helps ...

On Tue, Sep 29, 2009 at 10:28 AM, vishnu <email address hidden> wrote:

> Hi, I too do not know where to apply the patch client.py in the paramiko
> library. Any information regarding teh same would help me. Thank you.
>
> --
> SSHClient.connect fails on Windows XP
> https://bugs.launchpad.net/bugs/411910
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Paramiko SSH2 library for python: New
>
> Bug description:
> I have just upgraded to Paramiko 1.7.5 (Ernest), and tested it on a Windows
> XP host. Attempting to call SSHClient.connect fails with the following
> exception:
> paramiko.SSHException: No suitable address family for titan
>
> This bug appears to have been introduced with the new IPv6 support. Calling
> getaddrinfo may yield results with socktype=0, which are silently ignored by
> Paramiko. If you specify a hint of socket.SOCK_STREAM, the resulting
> socktype should be socket.SOCK_STREAM. i.e.
> socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM)
>

Revision history for this message
Lawrence (v-launchpad-lklyne-co-uk) wrote :

Additional information:
I have the problem possibly because I am attempting to connect to a local loopback address, one of my test case setups.

Interactive to the python interpreter for this gives:

>>> socket.getaddrinfo('127.0.0.1',22)
[(2, 0, 0, '', ('127.0.0.1', 22))]

socktype = 0
proto = 0

Revision history for this message
Robey Pointer (robey) wrote :

patched on head.

Changed in paramiko:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Robey Pointer (robey)
milestone: none → 1.7.6
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.