Skip to content

Added the ability to explicitly specify the port on which the telnet, ssh is running for each host - #3860

Open
rajven wants to merge 1 commit into
ytti:masterfrom
rajven:master
Open

Added the ability to explicitly specify the port on which the telnet, ssh is running for each host#3860
rajven wants to merge 1 commit into
ytti:masterfrom
rajven:master

Conversation

@rajven

@rajven rajven commented Jul 3, 2026

Copy link
Copy Markdown

Added the ability to explicitly specify the port on which the telnet or ssh service is running for each host, i.e.

in config:
source:
default: csv
csv:
file: "/home/oxidized/.config/oxidized/router.db"
delimiter: !ruby/regexp /:/
map:
name: 0
ip: 1
username: 2
password: 3
model: 4
added: input_port: 5
input: 6
group: 7
vars_map:
enable: 8
comware_cmdline: 9

in router.db:
router:192.168.1.1:admin:password:routeros:60022:ssh:Gateways::

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

…or ssh service is running for each host, i.e.

in config:
source:
  default: csv
  csv:
     file: "/home/oxidized/.config/oxidized/router.db"
     delimiter: !ruby/regexp /\:/
     map:
       name: 0
       ip: 1
       username: 2
       password: 3
       model: 4
added:       input_port: 5
       input: 6
       group: 7
     vars_map:
       enable: 8
       comware_cmdline: 9

in router.db:
router:192.168.1.1:admin:password:routeros:60022:ssh:Gateways::
@ytti

ytti commented Jul 3, 2026

Copy link
Copy Markdown
Owner

You can of course already do this for SSH, Telnet per node. And collapsing it as input port for node suggests we guarantee ssh and telnet and other inputs all listen on same port, as same node way traverse multiple inputs, this is not a safe assumption.

@rajven

rajven commented Jul 6, 2026

Copy link
Copy Markdown
Author

You can of course already do this for SSH, Telnet per node. And collapsing it as input port for node suggests we guarantee ssh and telnet and other inputs all listen on same port, as same node way traverse multiple inputs, this is not a safe assumption.

That's the whole point — so that for a specific equipment, you can explicitly specify the port on which SSH or Telnet is running.

@ytti

ytti commented Jul 6, 2026

Copy link
Copy Markdown
Owner

I dont follow. When would you need this? Why wont specifying telnet or ssh port as needed work?

@rajven

rajven commented Jul 6, 2026

Copy link
Copy Markdown
Author

Well, look - I have a group of devices, for example mikrotik, for which ssh runs on a non-standard port, for example 5122. And all the other mikrotik are on standard port 22. What should I do in this situation?

@ytti

ytti commented Jul 6, 2026

Copy link
Copy Markdown
Owner

You set ssh_port for the 5122 device, using vars_map.

@rajven

rajven commented Jul 6, 2026

Copy link
Copy Markdown
Author

Is it possible to do this selectively on the device?

@ytti

ytti commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Technically depends on source, in CVS you point to an index which has to exist, in SQL you point to a row which has to exist, but even then it can return falsy value. If it returns falsy value, default 22 will be used.

You can further customise what is returned between source and actual node by adding hook. Let's say you want 2222 for all, except 2223 for few, but you don't want to write 2222 to all. Then you could write a hook that'll return 2222 on falsy value, otherwise configured. value.
Of course you could also write 2222 for e.g. group, and if source returns nil, I'll continue searching lower precedence until it finds 2222 from group. If source returns false, it'll terminate there, and won't consider any lower precedence values.

@rajven

rajven commented Jul 6, 2026

Copy link
Copy Markdown
Author

Why such difficulties? And then how can you not forget what you did that hook for?

@ytti

ytti commented Jul 6, 2026

Copy link
Copy Markdown
Owner

It was just an example, you don't need to do hook. You can just not configure truthy value in source for node which should use 22, and only configure truthy value for node which should use it.

In your case:

router:192.168.1.1:admin:password:routeros:60022:ssh:Gateways::
router:192.168.1.2:admin:password:routeros:nil:ssh:Gateways::
router:192.168.1.3:admin:password:routeros:22:ssh:Gateways::

Which is in no way different to what you propose, as the field has to exist in your case too.
Both 2 and 3 will use 22.
If you have SQL, and you have row here, it'll natively be falsy or integer, so it'll just work. Same with JSON file.

@rajven

rajven commented Jul 6, 2026

Copy link
Copy Markdown
Author

I'll try it tomorrow, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants