diff --git a/paramiko/client.py b/paramiko/client.py index 5b71958..4fa28e5 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():