Unfortunately, I am responsible for this regression. I submitted a patch 'fixing' IPv6 support which got in the latest release, but the method fails on Windows (I assume that's what you're using?). Worse that it fails with even IPv4 as I see you're connecting on "127.0.0.1"... ugh
After looking at Python docs [1], I am attaching a correct patch against trunk. Best, Shikhar [1] http://docs.python.org/library/socket.html#example "Echo client program" On Wed, Aug 12, 2009 at 3:24 AM, 李昊<lenc...@gmail.com> wrote: > Hi, > > I'm a new user of paramiko and when I tried to start a ssh client using the > code below,I got an exception saying: > "paramiko.SSHException: No suitable address" > > import paramiko > ssh = paramiko.SSHClient() > > ssh.set_missing_host_key_policy( > paramiko.AutoAddPolicy()) > > ssh.connect('127.0.0.1', username='xxx', > > password='xxx') > > But when I using SFTPClient with the same username and password, everything > goes smoothly. I can logon the server and put/get files. > > My python version is 2.5, does anybody had this experience before? Any > advice will be appreciated much. > > Thank you! > -- > Lenciel > > _______________________________________________ > paramiko mailing list > paramiko@lag.net > http://www.lag.net/cgi-bin/mailman/listinfo/paramiko >
diff --git a/paramiko/client.py b/paramiko/client.py index 1808843..d651e0d 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -273,21 +273,25 @@ class SSHClient (object): establishing an SSH session @raise socket.error: if a socket error occurred while connecting """ - for (family, socktype, proto, canonname, sockaddr) in \ - socket.getaddrinfo(hostname, port): - if socktype==socket.SOCK_STREAM: - af = family - addr = sockaddr - break - else: - raise SSHException('No suitable address family for %s' % hostname) - sock = socket.socket(af, socket.SOCK_STREAM) - if timeout is not None: + sock = None + for res in socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM): + af, socktype, proto, canonname, sa = res try: - sock.settimeout(timeout) - except: - pass - sock.connect(addr) + sock = socket.socket(af, socktype, proto) + except socket.error: + sock = None + continue + sock.settimeout(timeout) + try: + sock.connect(sa) + except socket.error: + sock.close() + sock = None + continue + break + if sock is None: + raise SSHException("Could not open socket to " % hostname) + t = self._transport = Transport(sock) if self._log_channel is not None:
_______________________________________________ paramiko mailing list paramiko@lag.net http://www.lag.net/cgi-bin/mailman/listinfo/paramiko