forked from coop-cloud/abra
fix: log what keys are loaded with the ssh-agent
Closes coop-cloud/organising#249.
This commit is contained in:
parent
cc37615d83
commit
56c3e070f5
|
@ -409,12 +409,31 @@ func connect(username, host, port string, authMethod ssh.AuthMethod, timeout tim
|
|||
}
|
||||
|
||||
func connectWithAgentTimeout(host, username, port string, timeout time.Duration) (*Client, error) {
|
||||
logrus.Debugf("using ssh-agent to make an SSH connection for %s", host)
|
||||
|
||||
sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
authMethod := ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers)
|
||||
agentCl := agent.NewClient(sshAgent)
|
||||
authMethod := ssh.PublicKeysCallback(agentCl.Signers)
|
||||
|
||||
loadedKeys, err := agentCl.List()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var convertedKeys []string
|
||||
for _, key := range loadedKeys {
|
||||
convertedKeys = append(convertedKeys, key.String())
|
||||
}
|
||||
|
||||
if len(convertedKeys) > 0 {
|
||||
logrus.Debugf("ssh-agent has these keys loaded: %s", strings.Join(convertedKeys, ","))
|
||||
} else {
|
||||
logrus.Debug("ssh-agent has no keys loaded")
|
||||
}
|
||||
|
||||
return connect(username, host, port, authMethod, timeout)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue