Skip to content

Commit

Permalink
Fixes panic when SSH_AUTH_SOCK is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Dementyev committed Mar 24, 2022
1 parent d8b6dcf commit f891dbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ec2connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const defaultUser = "ec2-user"
func ConnectEC2(sshEntries lib.SSHEntries, sshConfigPath string, args []string) {
// get the pub key from the ssh agent first
sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
log.WithError(err).Fatal("can't connect to ssh agent, maybe SSH_AUTH_SOCK is unset?")
}

keys, err := agent.NewClient(sshAgent).List()
if err != nil || len(keys) < 1 {
Expand Down

0 comments on commit f891dbc

Please sign in to comment.