fix: log what keys are loaded with the ssh-agent
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
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) {
|
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"))
|
sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
return connect(username, host, port, authMethod, timeout)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue