diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2012-10-12 09:50:51 +0200 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2013-04-27 20:36:45 -0700 |
commit | 81f87f1d5eb4fa89472114f45faa3a994fc7db7d (patch) | |
tree | ae2207022fd860f56567c8ef53e1ba60acc84ad7 | |
parent | 080bece2586d348b9791892cd6e5670a7afdb1a9 (diff) |
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.
-rw-r--r-- | paramiko/client.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/paramiko/client.py b/paramiko/client.py index 5b719581..4fa28e5c 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -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(): |