NetXMS Support Forum

Development => General => Topic started by: pvo on December 29, 2020, 03:13:54 PM

Title: SSH.Command with different port
Post by: pvo on December 29, 2020, 03:13:54 PM
I've seen that that the SSH.Command uses fixed port 22.
It would be useful to have the possibility to specify different port. Can I add the fifth optional parameter port with default value 22 to the SSH.Command? Would you add it this change to your sources?
Title: Re: SSH.Command with different port
Post by: Victor Kirhenshtein on December 29, 2020, 08:01:43 PM
Hi,

port can be specified as part of host name after : character. This is relevant piece of code from SSH subagent: https://github.com/netxms/netxms/blob/819a9418773ce2fe4b5589397a70716d736c652e/src/agent/subagents/ssh/handlers.cpp#L39 (https://github.com/netxms/netxms/blob/819a9418773ce2fe4b5589397a70716d736c652e/src/agent/subagents/ssh/handlers.cpp#L39)

Best regards,
Victor
Title: Re: SSH.Command with different port
Post by: pvo on December 29, 2020, 08:10:58 PM
Hi Victor,

thank you for your answer. It was good idea first ask before I started  to modify the sources  ;).

If I understand this right, there is no such posibility for the NXSL function executeSSHCommand. Is it so?
Title: Re: SSH.Command with different port
Post by: Victor Kirhenshtein on December 29, 2020, 08:26:02 PM
Yes, that's actually a problem - executeSSHCommand uses SSH settings from node it is called on, and it is actually not possible to set SSH port for node.
In NXSL workaround is to use agentReadList - all that executeSSHCommand does is reading agent list with necessary arguments (properly escaped). But it has to be fixed anyway - SSH port for node definitely should be configurable, and maybe optional port number, login, and password arguments can be added to executeSSHCommand.

Best regards,
Victor
Title: Re: SSH.Command with different port
Post by: pvo on December 29, 2020, 08:32:08 PM
Thank you.
I know this workaround.