How to change SSH port on Manjaro Linux

In some cases, to improve security we need to change the default ssh port on Manjaro or Arch Linux. For example we want to change it from port 22 to port 2222. By changing this default port, we will improve our system security from the start. OK, there are few things we need to do in order to change this ssh port. Before we go through, I assume you have a running SSH Server on Manjaro. 

Steps to change SSH port on Manjaro Linux

Step 1. Check the status of the SSH Server

Use the following command to get the current status of SSH Server 
sudo systemctl status sshd
You should see something like this:

Make sure the sshd service status is active (running).

Step 2. Edit the sshd_config

The main configuration of the SSH server is stored in /etc/ssh/sshd_config. To change the default port, open and edit the sshd_config file with your favorite text editor such as nano. 
sudo nano /etc/ssh/sshd_config
Find and change the following section:
Port 2222
#PermitRootLogin yes
#AddressFamily any
#ListenAddress 0.0.0.0
As you can see, I change the port to 2222. Close and save the file and then restart ssh service
sudo systemctl restart sshd
Step 3. Test the new port
Now use other computer and try to connect to the computer with the following command:
ssh -p 2222 dhani@10.34.0.10
Change the credentials with your username and IP address.


EmoticonEmoticon