From aec11bda28d2ee5ba70c6a2b96c4b77ebb824201 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 26 Oct 2021 00:33:18 +0200 Subject: [PATCH] fix: add ssh conn time outs --- pkg/ssh/ssh.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index da7a4aca7..c403cc356 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -2,6 +2,7 @@ package ssh import ( "os/user" + "time" "github.com/AlecAivazis/survey/v2" "github.com/kevinburke/ssh_config" @@ -71,7 +72,7 @@ func New(domainName, sshAuth, username, port string) (*simplessh.Client, error) if sshAuth == "identity-file" { var err error - client, err = simplessh.ConnectWithAgent(hostConfig.Host, hostConfig.User) + client, err = simplessh.ConnectWithAgentTimeout(hostConfig.Host, hostConfig.User, 5*time.Second) if err != nil { return client, err } @@ -85,7 +86,7 @@ func New(domainName, sshAuth, username, port string) (*simplessh.Client, error) } var err error - client, err = simplessh.ConnectWithPassword(hostConfig.Host, hostConfig.User, password) + client, err = simplessh.ConnectWithPasswordTimeout(hostConfig.Host, hostConfig.User, password, 5*time.Second) if err != nil { return client, err }