From 20e3306f3d8554648ac9cf2c1e33b780b7dfd7ff Mon Sep 17 00:00:00 2001 From: Shikhar Bhushan Date: Sat, 18 Apr 2009 18:26:12 +0200 Subject: [PATCH 1/2] fix ipv6 support in SSHClient --- paramiko/client.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/paramiko/client.py b/paramiko/client.py index 52038bc..89e4ee1 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -273,17 +273,21 @@ class SSHClient (object): establishing an SSH session @raise socket.error: if a socket error occurred while connecting """ - if len(hostname.split(':')) > 1: - sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + for (family, socktype, proto, canonname, sockaddr) in \ + socket.getaddrinfo(hostname, port): + if socktype==socket.SOCK_STREAM: + af = family + ADDR = sockaddr + break else: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + raise SSHException('No suitable address family for %s' % hostname) + sock = socket.socket(af, socket.SOCK_STREAM) if timeout is not None: try: sock.settimeout(timeout) except: pass - - sock.connect((hostname, port)) + sock.connect(addr) t = self._transport = Transport(sock) if self._log_channel is not None: @@ -316,6 +320,8 @@ class SSHClient (object): else: key_filenames = key_filename self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys) + if agent_forwarding: + self._forward_agent() def close(self): """ @@ -474,4 +480,4 @@ class SSHClient (object): def _log(self, level, msg): self._transport._log(level, msg) - + \ No newline at end of file From 044814ba16467264173b9c6573e410d6cbceb6e0 Mon Sep 17 00:00:00 2001 From: Shikhar Bhushan Date: Sat, 18 Apr 2009 18:50:19 +0200 Subject: [PATCH 2/2] typo --- paramiko/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paramiko/client.py b/paramiko/client.py index 89e4ee1..1644d46 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -277,7 +277,7 @@ class SSHClient (object): socket.getaddrinfo(hostname, port): if socktype==socket.SOCK_STREAM: af = family - ADDR = sockaddr + addr = sockaddr break else: raise SSHException('No suitable address family for %s' % hostname) @@ -480,4 +480,4 @@ class SSHClient (object): def _log(self, level, msg): self._transport._log(level, msg) - \ No newline at end of file +