@@ -44,6 +44,7 @@ type Config struct {
4444 SSHHost string
4545 SSHUser string
4646 SSHPassword string
47+ SSHPort int
4748 validated bool
4849}
4950
@@ -52,7 +53,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {
5253
5354 fs .StringVarP (& config .Host , "host" , "H" , "127.0.0.1" ,
5455 "Host name, IP Address of the remote host" )
55- fs .IntVarP (& config .Port , "port" , "p" , 0 , "Port number WinRM" ) // TODO: document default
56+ fs .IntVarP (& config .Port , "port" , "p" , 0 , "Port number WinRM (default: 5985 & 5986 for TLS)" )
5657
5758 fs .StringVarP (& config .User , "user" , "U" , "" , "Username of the remote host" )
5859 fs .StringVarP (& config .Password , "password" , "P" , "" , "Password of the user" )
@@ -72,6 +73,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {
7273
7374 // AuthSSH
7475 fs .StringVar (& config .SSHHost , "sshhost" , "" , "SSH Host (mandatory if --auth=SSH)" )
76+ fs .IntVarP (& config .SSHPort , "sshport" , "" , 22 , "SSH Port" )
7577 fs .StringVar (& config .SSHUser , "sshuser" , "" , "SSH Username (mandatory if --auth=SSH)" )
7678 fs .StringVar (& config .SSHPassword , "sshpassword" , "" , "SSH Password (mandatory if --auth=SSH)" )
7779
@@ -212,9 +214,8 @@ func (c *Config) Run(timeout time.Duration) (rc int, output string, err error) {
212214 return & winrm.ClientAuthRequest {}
213215 }
214216 case AuthSSH :
215- // TODO: port configuration?
216217 var sshClient * ssh.Client
217- sshClient , err = ssh .Dial ("tcp" , c . SSHHost + ":22" , & ssh.ClientConfig {
218+ sshClient , err = ssh .Dial ("tcp" , fmt . Sprintf ( "%s:%d" , c . SSHHost , c . SSHPort ) , & ssh.ClientConfig {
218219 User : c .SSHUser ,
219220 Auth : []ssh.AuthMethod {ssh .Password (c .SSHPassword )},
220221 HostKeyCallback : ssh .InsecureIgnoreHostKey (), //nolint:gosec // TODO: really?
0 commit comments