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

,

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

Leave a Reply

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