Deprecated: Hook custom_css_loaded is deprecated since version jetpack-13.5! Use WordPress Custom CSS instead. Jetpack no longer supports Custom CSS. Read the WordPress.org documentation to learn how to apply custom styles to your site: https://wordpress.org/documentation/article/styles-overview/#applying-custom-css in /srv/www/srvfail.com/public_html/wp-includes/functions.php on line 6078
safessh Archives ⋆ SysAdminStuff

Reset SSH, and find SSH port on cPanel/WHM server

If you lock yourself out of SSH access to your cPanel server or if you do not know on which port your SSH server is running there are several ways you can gain back SSH access to your server.

Flush iptables

If your  IP got locked out in iptables you can use one of cPanel autofixer scripts to flush all iptables chains so your IP can reach SSH on your server again.

Script can be called by adding “scripts2/doautofixer?autofix=iptablesflush” to the end of the WHM url in your browser, and should look something like this:

https://server.domain.tld:2087/cpsess1290981925/scripts2/doautofixer?autofix=iptablesflush

flushing iptables

Reset SSH

If you SSH server is not accessible because of a broken configuration or anything else and is not restarting properly through Home »Restart Services »SSH Server (OpenSSH) in WHM you can try starting safesshrestart script which will kill any running instance of sshd and start a new process on port 22, or if that port is taken on first available port after that, like port 23.

Script can be started by adding “scripts2/doautofixer?autofix=safesshrestart” to the end of your WHM url and should look something like this:

https://server.domain.tld:2087/cpsess1290981925/scripts2/doautofixer?autofix=safesshrestart

Pay attention to the output in WHM when script runs, it will say on which port was SSH started.

safesshrestart

Find out your SSH port

If you are not sure on which port is your SSH server running you can find that out on two ways.

You can use the Restart Services part of WHM and restart SSH by going to Home »Restart Services »SSH Server (OpenSSH) in WHM and watching the output in WHM after you restart SSH, it will say on which port is SSH listening.

Other option is to use an API call to show the port.
You can do that by adding “xml-api/cpanel?user=cpanel&cpanel_xmlapi_apiversion=1&cpanel_xmlapi_module=SSH&cpanel_xmlapi_func=getport” to the end of your WHM url which should look something like this:

https://server.domain.tld:2087/cpsess1290981925/xml-api/cpanel?user=cpanel&cpanel_xmlapi_apiversion=1&cpanel_xmlapi_module=SSH&cpanel_xmlapi_func=getport

You can find out more about WHM autofixers on following link:

https://documentation.cpanel.net/display/ALD/WHM+FAQ#WHMFAQ-WhatistheWHMAutofixer?

Full list of all autofixers can be found here:

http://httpupdate.cpanel.net/autofixer/