Skip to content

Commit

Permalink
fix panic if there are no identities loaded into ssh-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Dementiev committed Nov 13, 2019
1 parent a1c5ad7 commit 2f7802b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ func ConnectSSH(profile, cluster, taskDefinitionName, containerName, shell, serv
sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))

keys, err := agent.NewClient(sshAgent).List()
if err != nil || len(keys) < 1 {
ctx.WithError(err).Error("Can't get public keys from ssh agent. Please ensure you have the ssh-agent running and have at least one identity added (with ssh-add)")
if err != nil {
ctx.WithError(err).Error("Can't get public keys from ssh agent. Please ensure you have the ssh-agent running")
return 1, err
}
if len(keys) < 1 {
ctx.Error("Can't get public keys from ssh agent. Please ensure you have at least one identity added (with ssh-add)")
return 1, err
}
pubkey := keys[0].String()
Expand Down

0 comments on commit 2f7802b

Please sign in to comment.