Change the default SSH Port
As the second video in this series on making SSH access to a CentOS Linux server more secure, this tutorial will
show you:
How to Change the Default SSH Port in CentOS
- To change the default SSH port, which is 22, at the command prompt type
sudo vi /etc/ssh/sshd_config
and press Enter.
This will bring up the sshd server system-wide configuration file.
- Locate the
#Port 22 line immediately below the introductory text, place your cursor at the end
of the line, press Insert, and press Enter.
Then type Port [your custom port]
where your custom port is any unassigned port
number (in this tutorial, the new SSH port number is 19350
Press the Esc key
- Then, type :w and press Enter to save the file, and type :q and press Enter
to exit the vi editor.
- In order for changes to take effect, restart the SSH service by executing
sudo service sshd restart
at the command prompt.
Logout from the server
You will now be able to connect to your server using the custom SSH port number that you set.
Be sure to see the next video in this series: How to Create and Use SSH Keys with PuTTY