How To Change SSH Port | Linux Tutorial 2020 | Step By Step

Опубликовано: 06 Апрель 2020
на канале: Linux Teaching House
25
0

860K Subscribers . 478K Views

How To Change SSH Port CentOS Linux Step by Step
you can change Centos 5/6/7/8 and Redhat Server also
Keep watching my video

Changing the SSH port on your Linux system can help improve security by making it more difficult for attackers to discover and target your SSH service. Here's how to change the SSH port on a Linux system:

Log in to your Linux system using SSH or open a terminal window.

Edit the SSH configuration file /etc/ssh/sshd_config using your preferred text editor. For example, to use the nano editor, type:

sudo nano /etc/ssh/sshd_config

Find the line that contains the #Port 22 directive, and remove the # at the beginning of the line to uncomment it.

#Port 22
Change the number 22 to your desired port number. For example, if you want to use port 2222, the line should look like this:

yaml
Port 2222
Save the changes and exit the text editor.

Restart the SSH service to apply the changes:


sudo systemctl restart sshd
Verify that the SSH service is running on the new port by connecting to the system using the new port number:

ssh username@server_ip -p 2222
Replace username with your username and server_ip with the IP address of your server. The -p option is used to specify the new port number.

If the connection is successful, you have successfully changed the SSH port on your Linux system.

Note: Make sure to add the new SSH port to your firewall rules if you are using a firewall on your system. Otherwise, you may be unable to connect to your system using SSH on the new port.

Please Subscribe and click the notification bell so you never miss a video
Thank You For Watching


#LinuxTipsandTricks2020 #LinuxServer #LinuxTeachingHouse #LinuxTutorial2020