[paramiko] client.py in version 1.6.4
CK Tan
cktan at greenplum.com
Thu Dec 28 17:27:15 PST 2006
In reference to bug# 69330 ("client.py doesn't handle nonexistant key
files https://bugs.launchpad.net/products/paramiko/+bug/69330),
the bug fix introduced another bug:
keyfiles = []
rsa_key = os.path.expanduser('~/.ssh/id_rsa')
dsa_key = os.path.expanduser('~/.ssh/is_dsa')
if os.path.isfile(rsa_key):
keyfiles.append((RSAKey, rsa_key))
if os.path.isfile(dsa_key):
keyfiles.append((DSSKey, dss_key))
for pkey_class, filename in keyfiles:
---> filename = os.path.expanduser(''~/.ssh/' + filename)
try:
key = pkey_class.from_private_key_file(filename,
password)
self._log(DEBUG, 'Trying discovered key %s in %s' %
(hexlify(key.get_fingerprint()), filename))
self._transport.auth_publickey(username, key)
return
except SSHException, e:
saved_exception = e
except IOError, e:
saved_exception = e
The indicated line above may result in ~/.ssh/ being expanded more
than once,
resulting in the error below:
% python
Python 2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
>>> paramiko.__version__
'1.6.4 (yanma)'
>>> s = paramiko.SSHClient()
>>> s.load_system_host_keys()
>>> s.connect('localhost')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/cktan/w/cdb2/mppMgmt/bin/lib/paramiko/client.py",
line 277, in connect
self._auth(username, password, pkey, key_filename)
File "/Users/cktan/w/cdb2/mppMgmt/bin/lib/paramiko/client.py",
line 405, in _auth
raise saved_exception
IOError: [Errno 2] No such file or directory: '/Users/cktan/.ssh//
Users/cktan/.ssh/id_rsa'
>>>
Suggested fix:
condition the clause by
if filename.find('/.ssh/') >= 0: filename = os.path.expanduser
('~/.ssh/' + filename)
More information about the paramiko
mailing list