fix: add ssh conn time outs

This commit is contained in:
decentral1se 2021-10-26 00:33:18 +02:00
parent 9a513a0700
commit aec11bda28
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 3 additions and 2 deletions

View File

@ -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
}