forked from pyinfra-dev/pyinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyinfra/connectors: Fix overwriting of users known_hosts file (pyinfr…
…a-dev#1209) This fixes issue pyinfra-dev#1209, making it so that we append new keys to the users known_hosts file instead of overwriting it. Additionally: - Added a testcase that should discover this breaking in the future. - Broke out the append functionality into a "append_hostkey" function, making it so we don't needlessly reuse code for AskPolicy and - AcceptNewPolicy. - Linting actually correct this time. This commit changes the behaviour when adding a new key to known_hosts: Previous behaviour when adding a new key: - Create a paramiko.HostKeys object - Read the users known_hosts file - Add the new key to the object - Save the object, overwriting the users host_keys file. New behaviour: - Create a paramiko.HostKeyEntry object using the new hostname and corresponding key. - Append this key to the existing known_hosts file.
- Loading branch information
Showing
3 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters