Fix bug #283: Multiple keys are added to authorized_keys without line breaks#424
Open
blaisemGH wants to merge 2 commits intoatmoz:masterfrom
Open
Fix bug #283: Multiple keys are added to authorized_keys without line breaks#424blaisemGH wants to merge 2 commits intoatmoz:masterfrom
blaisemGH wants to merge 2 commits intoatmoz:masterfrom
Conversation
Ensure authorized_keys delimits keys on newline
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
While
ssh-keygencreates public keys that end in a newline (which is used in current tests), sometimes this newline is lost, e.g., when the key is mounted by a configmap in k8s. In this scenario, the current implementation breaks the authorized_keys file, making sftp with subsequent public keys impossible.Before
Multiple keys for a single host are merged into authorized_keys via cat and append, e.g.,
cat $keyFile >> authorized_keys. When a key does not have a trailing newline, the append concatenates the next key on the same line as the previous key, and the keys can no longer be parsed.After
Using
paste -d "\\n" -sinserts a newline between public keys if and only if the key is missing a trailing newline.Example (pseudo code)
Before:
After: