<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SSH subagent - using an alternative port (code/example)]]></title><description><![CDATA[<p dir="auto">looking at the 2.2.x source code in <code>./netxms/src/agent/subagents/ssh</code></p>
<p dir="auto">in here, the handlers.cpp file defines the remote SSH port 22.<br />
Also here are a group of parameters passed into H_SSHCommand()</p>
<p dir="auto">I am interested in variable/pointer set with this function <code>_tcschr(hostName, _T(':'));</code></p>
<pre><code>/**
 * Generic handler to execute command on any host
 */
LONG H_SSHCommand(const TCHAR *param, const TCHAR *arg, TCHAR *value, AbstractCommSession *session)
{
   TCHAR hostName[256], login[64], password[64], command[256];
   if (!AgentGetParameterArg(param, 1, hostName, 256) ||
       !AgentGetParameterArg(param, 2, login, 64) ||
       !AgentGetParameterArg(param, 3, password, 64) ||
       !AgentGetParameterArg(param, 4, command, 256))
      return SYSINFO_RC_UNSUPPORTED;

   UINT16 port = 22;
   TCHAR *p = _tcschr(hostName, _T(':'));
   if (p != NULL)
   {
      *p = 0;
      p++;
      port = (UINT16)_tcstoul(p, NULL, 10);
   }
</code></pre>
<p dir="auto">We understand from documentation and from forums to use SSH.Command() -- Is anyone using the alternative port feature? I assume it should be used in DCI collection for Data Parameter (as an SSH origin) with this example:</p>
<pre><code>SSH.Command(100.64.45.218:1916,tiger,lemur,"cat /tmp/run/stats/wireless.json")
</code></pre>
<p dir="auto">Is this accurate? a packet trace reveals port 22 is used <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--confused" style="height:1.4em;width:auto;vertical-align:middle" title=":-\" alt="😕" /></p>
<p dir="auto">... The command above works for ./bin/nxget but not for DCI collection. For that, i simply enter the command "cat /tmp/run..." but nxms connects to port 22</p>
]]></description><link>https://forum.netxms.org/topic/5486/ssh-subagent-using-an-alternative-port-code-example</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:35:23 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/5486.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Mar 2018 16:57:06 GMT</pubDate><ttl>60</ttl></channel></rss>