Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
fix: restart sshd if connection refused
Browse files Browse the repository at this point in the history
  • Loading branch information
eliobischof committed Jan 28, 2020
1 parent e2b437c commit 4a939b6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/operator/nodeagent/dep/sshd/dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ func (s *sshdDep) Current() (pkg common.Package, err error) {
if len(fields) > 1 {
value = fields[1]
}
checkIP := "127.0.0.1"
if value != "[::]:22" && value != "0.0.0.0:22" {
if pkg.Config == nil {
pkg.Config = make(map[string]string)
}
pkg.Config["listenaddress"] = value
checkIP = strings.Split(value, ":")[0]
pkg.Config["listenaddress"] = checkIP
}
out, _ := exec.Command("ssh", "-T", checkIP).CombinedOutput()
if strings.Contains(string(out), "Connection refused") {
if pkg.Config == nil {
pkg.Config = make(map[string]string)
}
pkg.Config["listening"] = "false"
}
return pkg, nil
}
Expand Down

0 comments on commit 4a939b6

Please sign in to comment.