Load host entries from the known_hosts file(s) before writing the file from RAM to disk. Avoids loss of host entries in case other SSH clients have written to the known_hosts file(s) meanwhile.
This commit is contained in:
parent
080bece258
commit
81f87f1d5e
|
@ -186,6 +186,12 @@ class SSHClient (object):
|
|||
|
||||
@raise IOError: if the file could not be written
|
||||
"""
|
||||
|
||||
# update local host keys from file (in case other SSH clients
|
||||
# have written to the known_hosts file meanwhile.
|
||||
if self.known_hosts is not None:
|
||||
self.load_host_keys(self.known_hosts)
|
||||
|
||||
f = open(filename, 'w')
|
||||
f.write('# SSH host keys collected by paramiko\n')
|
||||
for hostname, keys in self._host_keys.iteritems():
|
||||
|
|
Loading…
Reference in New Issue