Skip to content

Commit

Permalink
Prefer ssh-agent keyring instead of ssh-key
Browse files Browse the repository at this point in the history
  • Loading branch information
rivik committed Aug 25, 2020
1 parent 8012804 commit 47b3521
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ func createRunnerFactory(
}

var keyring agent.Agent
sshAgentAlive := false
if os.Getenv("SSH_AUTH_SOCK") != "" {
sock, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
Expand All @@ -724,11 +725,12 @@ func createRunnerFactory(
}

keyring = agent.NewClient(sock)
sshAgentAlive = true
} else {
keyring = agent.NewKeyring()
}

if sshKeyPath != "" {
if !sshAgentAlive && sshKeyPath != "" {
err := readSSHKey(keyring, sshKeyPath)
if err != nil {
return nil, hierr.Errorf(
Expand Down

0 comments on commit 47b3521

Please sign in to comment.