/ ssh

SSHd additional service port

So many a times we require the service of SSH to be served on another port than the default 22.

I faced a situation where my ISP was blocking port 22 data transfer so I had to make my server allow ssh connections on another port than 22, i chose 222

Its quite simple to achieve it
While in the machine, add a new line to the file of


with the text of

Port 222

restart the service

by typing,

$ service sshd.service restart

You can look at the status of the service to see all is good and try ssh'ing to the server.

$ service sshd.service status

Test if the additional port is allowed,

$ ssh <hostname/ip_addr> -p <port>

If you are unable to then maybe your firewall could be blocking.

  1. Make sure that any custom rules from your AWS/ISP/etc are allowing access to the port set.
  2. Make sure your Linux box firewall is allowing the port
# semanage port -a -t ssh_port_t -p tcp 222

If you require a shell script to do it on multiple machines, you can use a script I created. The script can be combined in a Jenkins job or Ansible for good use.

SSHd additional service port
Share this