From f891dbcc53955ab4f26c6aa1943356aa2c8501cf Mon Sep 17 00:00:00 2001 From: Eugene Dementyev Date: Thu, 24 Mar 2022 15:05:20 +1300 Subject: [PATCH] Fixes panic when SSH_AUTH_SOCK is not set --- lib/ec2connect/connect.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ec2connect/connect.go b/lib/ec2connect/connect.go index c37c183..52170f4 100644 --- a/lib/ec2connect/connect.go +++ b/lib/ec2connect/connect.go @@ -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 {