-
Notifications
You must be signed in to change notification settings - Fork 24
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
✨ Load ssh keys from home dir as a final ssh fallback #877
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ivan Milchev <[email protected]>
@@ -201,14 +204,48 @@ func prepareConnection(pCfg *providers.Config) ([]ssh.AuthMethod, []io.Closer, e | |||
} | |||
} | |||
|
|||
if len(sshSigners) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this below loading the ssh-agent certs since anything that is appended to sshSigners
after that is simply ignored. I feel like this was a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be correct here. The ssh agents authentication is activated in the cli if the user has not provided anything. Therefore we can remove the fallback to ssh-agent here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this code is not needed at all then?
// if no credential was provided, fallback to ssh-agent and ssh-config | ||
if len(pCfg.Credentials) == 0 { | ||
sshSigners = append(sshSigners, signers.GetSignersFromSSHAgent()...) | ||
} | ||
|
||
// If no keys were loaded so far, then attempt loading the default keys in the home directory | ||
if len(sshSigners) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is adding more implicit behavior. We should add a new credential type for ssh config and only load it when the credential type is set. The cli behaviour should stay implicit and therefore we need to add ssh_config and ssh_agent as default there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether ssh_config makes sense as a name. This is just using your default ssh settings for your user.
@@ -201,14 +204,48 @@ func prepareConnection(pCfg *providers.Config) ([]ssh.AuthMethod, []io.Closer, e | |||
} | |||
} | |||
|
|||
if len(sshSigners) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be correct here. The ssh agents authentication is activated in the cli if the user has not provided anything. Therefore we can remove the fallback to ssh-agent here.
The last resort for loading ssh keys at the moment was ssh-agent. However, if that loads no keys then we stop. This PR also attempts to load the keys located in
~/.ssh
(if they exist).