Skip to content

Commit

Permalink
refactor rename
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vasek <[email protected]>
  • Loading branch information
matejvasek committed Oct 22, 2021
1 parent 93ad9fe commit 712ff06
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/sshdialer/ssh_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,29 +222,30 @@ func NewSSHClientConfig(url *urlPkg.URL, config Config) (*ssh.ClientConfig, erro

// add signer from explicit identity parameter
if config.Identity != "" {
s, err := loadSignerFromFile(config.Identity, []byte(config.Identity), config.PassPhraseCallback)
signer, err := loadSignerFromFile(config.Identity, []byte(config.Identity), config.PassPhraseCallback)
if err != nil {
return nil, fmt.Errorf("failed to parse identity file: %w", err)
}
signers = append(signers, s)
signers = append(signers, signer)
}

s, err := getSignersFromAgent()
// pulls signers (keys) from ssh-agent
signersFromAgent, err := getSignersFromAgent()
if err != nil {
return nil, err
}
signers = append(signers, s...)
signers = append(signers, signersFromAgent...)

// if there is no explicit identity file nor keys from ssh-agent then
// add keys with standard name from ~/.ssh/
if len(signers) == 0 {
defaultKeyPaths := getDefaultKeys()
if len(defaultKeyPaths) == 1 {
s, err := loadSignerFromFile(defaultKeyPaths[0], []byte(config.PassPhrase), config.PassPhraseCallback)
signer, err := loadSignerFromFile(defaultKeyPaths[0], []byte(config.PassPhrase), config.PassPhraseCallback)
if err != nil {
return nil, err
}
signers = append(signers, s)
signers = append(signers, signer)
}
}

Expand Down

0 comments on commit 712ff06

Please sign in to comment.