- How to change the default SSH Port in Linux or Ubuntu which is 22 to increase the security.
- Just loginto your SSH server using root.
- Then use some editor like nano or vi to edit the sshd configuration file.
- Then type nano /etc/ssh/sshd_config
You can use other editor like vi if nano is not installed but working with vi is a little different.
- If nano is not installed you can install is using yum install nano in CentOS.
- Now lets save the new port number and exit.
- Press Ctrl + X
- Type Y for YES.
- Don’t change the file name and save it by the default location/name i.e. /etc/ssh/sshd_config. Just press enter.
- Once you have saved it just restart the system or the sshd service using the following command.
service sshd restart
- Then see the active port by following command
service sshd status
You can also see this complete guide on How to Change Default Port of SSH in Linux, Ubuntu or Centos on our official Youtube channel.