Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. SSH subagent - using an alternative port (code/example)

SSH subagent - using an alternative port (code/example)

Scheduled Pinned Locked Moved Support
1 Posts 1 Posters 12.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • meshnetM
    meshnetM
    meshnet
    wrote on last edited by
    #1

    looking at the 2.2.x source code in ./netxms/src/agent/subagents/ssh

    in here, the handlers.cpp file defines the remote SSH port 22.
    Also here are a group of parameters passed into H_SSHCommand()

    I am interested in variable/pointer set with this function _tcschr(hostName, _T(':'));

    /**
     * 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);
       }
    

    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:

    SSH.Command(100.64.45.218:1916,tiger,lemur,"cat /tmp/run/stats/wireless.json")
    

    Is this accurate? a packet trace reveals port 22 is used 😕

    ... 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

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    Powered by NodeBB Contributors
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups