SSH.Command with different port

Started by pvo, December 29, 2020, 03:13:54 PM

Previous topic - Next topic

pvo

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?

Victor Kirhenshtein

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

Best regards,
Victor

pvo

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?

Victor Kirhenshtein

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

pvo