Task: change the port number in Unix, whether Linux (Debian, CentOS, Ubuntu, RedHat) or FreeBSD.
Solution: go to /etc/ssh:
$ cd /etc/ssh
And open the sshd_config file for editing.
Now find the following option inside it:
Port 22
and change the port number to the one you need. Then save the file and exit the editor.
Now restart the SSH daemon.
Linux (Debian/Ubuntu):
$ sudo /etc/init.d/ssh restart
Linux (CentOS/RHEL):
$ sudo /etc/init.d/sshd restart
FreeBSD:
$ sudo /etc/rc.d/sshd restart
That's it... don't forget to allow the new port through the firewall!
Comments