Skip to content

Commit

Permalink
checking ssh is present or not?
Browse files Browse the repository at this point in the history
Signed-off-by: Kapil Sharma <[email protected]>
  • Loading branch information
h4l0gen committed Apr 11, 2024
1 parent cdb3b0d commit 797967b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions events/syscall/disallowed_ssh_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ var _ = events.Register(
)

func DisallowedSSHConnection(h events.Helper) error {
cmd := exec.Command("timeout", "1s", "ssh", "[email protected]", "-p", "22")
err := cmd.Run()
path, err := exec.LookPath("ssh")
if err != nil {
// If we don't have an SSH, just bail
return &events.ErrSkipped{
Reason: "ssh utility not found in path",
}
}
cmd := exec.Command("timeout", "1s", path, "[email protected]", "-p", "22")
err = cmd.Run()
if err != nil {
return err
}
Expand Down

0 comments on commit 797967b

Please sign in to comment.