Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Not supported at the moment is Kerberos.
```
Arguments:
-H, --host string Host name, IP Address of the remote host (default "127.0.0.1")
-p, --port int Port number WinRM
-p, --port int Port number WinRM (default: 5985 & 5986 for TLS)
-U, --user string Username of the remote host
-P, --password string Password of the user
-k, --insecure Don't verify the hostname on the returned certificate
Expand All @@ -37,6 +37,7 @@ Arguments:
--icingacmd string Executes commands of Icinga PowerShell Framework (e.g. Invoke-IcingaCheckCPU)
--auth string Authentication mechanism - NTLM | SSH (default "basic")
--sshhost string SSH Host (mandatory if --auth=SSH)
--sshport int SSH Port (default 22)
--sshuser string SSH Username (mandatory if --auth=SSH)
--sshpassword string SSH Password (mandatory if --auth=SSH)
-t, --timeout int Abort the check after n seconds (default 10)
Expand Down
7 changes: 4 additions & 3 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Config struct {
SSHHost string
SSHUser string
SSHPassword string
SSHPort int
validated bool
}

Expand All @@ -52,7 +53,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {

fs.StringVarP(&config.Host, "host", "H", "127.0.0.1",
"Host name, IP Address of the remote host")
fs.IntVarP(&config.Port, "port", "p", 0, "Port number WinRM") // TODO: document default
fs.IntVarP(&config.Port, "port", "p", 0, "Port number WinRM (default: 5985 & 5986 for TLS)")

fs.StringVarP(&config.User, "user", "U", "", "Username of the remote host")
fs.StringVarP(&config.Password, "password", "P", "", "Password of the user")
Expand All @@ -72,6 +73,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {

// AuthSSH
fs.StringVar(&config.SSHHost, "sshhost", "", "SSH Host (mandatory if --auth=SSH)")
fs.IntVarP(&config.SSHPort, "sshport", "", 22, "SSH Port")
fs.StringVar(&config.SSHUser, "sshuser", "", "SSH Username (mandatory if --auth=SSH)")
fs.StringVar(&config.SSHPassword, "sshpassword", "", "SSH Password (mandatory if --auth=SSH)")

Expand Down Expand Up @@ -212,9 +214,8 @@ func (c *Config) Run(timeout time.Duration) (rc int, output string, err error) {
return &winrm.ClientAuthRequest{}
}
case AuthSSH:
// TODO: port configuration?
var sshClient *ssh.Client
sshClient, err = ssh.Dial("tcp", c.SSHHost+":22", &ssh.ClientConfig{
sshClient, err = ssh.Dial("tcp", fmt.Sprintf("%s:%d", c.SSHHost, c.SSHPort), &ssh.ClientConfig{
User: c.SSHUser,
Auth: []ssh.AuthMethod{ssh.Password(c.SSHPassword)},
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //nolint:gosec // TODO: really?
Expand Down
Loading