Change Defualt SSH Port To Monitor



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,




check_ssh --help

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

Hope this answers your question :slight_smile:


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>




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

check_ssh -H -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?



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

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


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.



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.


great, thanks for the help guys.