How to change the ssh port in Linux servers – Command line option

Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote command-line login, remote command execution, and other secure network services between two networked computers that connects, via a secure channel over an insecure network, a server and a client (running SSH server and SSH client programs, respectively).
The default value for ssh port is 22. We can change the port value by editing its configuration file.
SSH configuration file.

# /etc/ssh/sshd_config

How to change the ssh port through command line?
Step 1: Open the SSH configuration file by using your favorite editor.

# vi /etc/ssh/sshd_config

Step 2: By default the port value is commented(Using default port #22) in SSH conf file. Uncomment the line and edit the port value to new.

# vi /etc/ssh/sshd_config
# Port 22
Port 2929

Step 3: Restart the SSH daemon

# service sshd restart
# /etc/init.d/sshd restart

For a cPanel server you can also use this script for restarting the SSH service.

# /scripts/restartsrv_sshd

That’s it. Now your server is more secure than the default SSH.

Related Links:
How to change cpanel port through command line
How to change the apache port via command line in cpanel
How to change ftp port – cpanel

Arunlal Ashok

Linux Server Administrator. I'm managing Linux servers since 2012. I started this blog to share and discuss my ideas. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *