Change Defualt SSH Port To Monitor


#1

Hi,

I was wondering how to make it so nagios monitors a different ssh port if you’ve changed the ssh default port on your server to something no standard to enhance security. Right now I get a connection refused alert due nagios not finding the port, thinking its still port 22.

Thanks for your time,

Dino


#2

Hi,

check_ssh --help

=> check_ssh -46] -t ] -r ] -p ]

Hope this answers your question :slight_smile:


#3

Awesome thanks!
I was able to find that command and looked at the help. I’m just having a bit of trouble with the exact syntax to use to change the port. Say I wanted to change it to port 12345. I tried this variations of this check_ssh -p <12345>

Thanks,

Dino


#4

I was able to run this command and it said ssh port ok

check_ssh -H xxx.xxx.xx.xx -p 12345
(ip x’d out)

In the nagios web admin it still shows that it is refusing the connection. Is there a way to change some reference to port that is checked in the web admin?

Thanks


#5

can you check that in your command definition of “check_ssh”, there is the option to specify the port ?

ie:
define command {
command_name check_ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$ -p $ARG1$
}

and then, use it as:
check_command check_ssh!12345


#6

Hi Sorry I missed your last reply and just read now.

I went into Nagios Admin > View Config > Services
Under check_ssh it shows $USER1$/check_ssh $ARG1$ $HOSTADDRESS$

but there’s no way to change the port.
Maybe this can be edited in the file check_ssh itself.

Thanks


#7

Edit the definition of check_ssh in your command.cfg file as Loose has indicated and use the service check as he mentioned and you will be fine.


#8

great, thanks for the help guys.

DIno