Skip to content

Duplicate entries in known_hosts #1339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pikeas opened this issue Apr 14, 2025 · 0 comments
Open

Duplicate entries in known_hosts #1339

pikeas opened this issue Apr 14, 2025 · 0 comments

Comments

@pikeas
Copy link

pikeas commented Apr 14, 2025

Describe the bug

Pyinfra creates duplicate entries in ~/.ssh/known_hosts when unable to connect.

To Reproduce

$ cat ~/.ssh/known_hosts
@cert-authority *.internal.example.com ssh-ed25519 <key> <comment>

$ pyinfra $host exec -- echo "hello world"
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
    Failed to load host keys from /Users/<user>/.ssh/known_hosts: ('@cert-authority *.internal.example.com ssh-ed25519 <key> <comment>', Error('Incorrect padding'))
    No host key for <host> found in known_hosts, accepting & adding to host keys file
    Added host key for <host> to known_hosts
    [<host>] Authentication error () (Authentication failed.)

--> Disconnecting from hosts...
--> pyinfra error: No hosts remaining!

$ pyinfra $host exec -- echo "hello world"
<same output>

$ pyinfra $host exec -- echo "hello world"
<same output>

$ cat ~/.ssh/known_hosts
@cert-authority *.internal.example.com ssh-ed25519 <key> <comment>
<host> ssh-ed25519 <key>
<host> ssh-ed25519 <key>
<host> ssh-ed25519 <key>

Expected behavior

Pyinfra should only add the key once. This is likely an edge case related to #1209, I ran into this while using pyinfra to inspect a server that was not yet signed by the CA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant