I m the way to upload files over sftp using paramiko but i am getting this error.
ri@ri-desktop:~/workspace/ssh$ python testssh.py
Traceback (most recent call last):
File "testssh.py", line 75, in
if host_keys.has_key(hostname):
AttributeError: 'HostKeys' object has no attribute 'has_key'
This is the code inside my test.py
hostkeytype = None
hostkey = None
files_copied = 0
try:
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))<br/>
except IOError:
try:
# try ~/ssh/ too, e.g. on windows
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
except IOError:
print '*** Unable to open host keys file'
host_keys = {}
if host_keys.has_key(hostname):
hostkeytype = host_keys[hostname].keys()[0]
hostkey = host_keys[hostname][hostkeytype]
print 'Using host key of type {0}'.format(hostkeytype)