Recreate the SSH connection every time through the loop.

This commit is contained in:
Bill Thiede 2022-11-28 13:21:55 -08:00
parent ef80985ca6
commit 9c3a0b21cc

View File

@ -255,15 +255,11 @@ func main() {
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Timeout: 5 * time.Second,
}
var c *ssh.Client
for {
if c == nil {
var err error
glog.Infof("Dialing %s@%s", user, host)
c, err = ssh.Dial("tcp", host, config)
if err != nil {
glog.Errorf("Error dialing %q: %v", host, err)
}
glog.Infof("Dialing %s@%s", user, host)
c, err := ssh.Dial("tcp", host, config)
if err != nil {
glog.Errorf("Error dialing %q: %v", host, err)
}
if c != nil {
stats, err := fetchSnapshotStats(host, c)