In this tutorial, we will show you how to change ssh port on Manjaro. In the realm of secure system administration, one of the first lines of defense against unauthorized access to your Linux server is SSH (Secure Shell). It serves as a robust and reliable means to access and manage your system remotely. However, with great power comes great responsibility, and part of ensuring your system’s security involves changing the default SSH port. The default port, 22, is well-known to potential attackers, making it a prime target for malicious activities.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step change ssh port on a Manjaro Linux.
- A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- Before making any changes to your system’s configuration, it’s a good practice to create a backup or snapshot. This ensures that you can revert to the previous state in case something goes wrong during the process. Backing up your system can be done using various methods, including manual backups or snapshots if your virtualization platform supports them.
Change Ssh Port on Manjaro
Step 1. Before running the tutorial below, make sure that our system is up to date:
sudo pacman -Syu
Step 2. Change ssh port on Manjaro.
We’ll start by locating and editing the SSH daemon configuration file, sshd_config. We recommend using command-line text editors like nano or vim.
sshd_config file, locate the line that specifies the SSH port. By default, it should be set to 22. Modify this line to specify the new port you want to use. Choose a port number that is not commonly used by other services to avoid conflicts. For this example, let’s use port 2222:
Step 3. Adjusting Firewall Rules.
With the SSH port changed, it’s crucial to update your firewall rules to allow incoming connections on the new port. Manjaro Linux uses the Uncomplicated Firewall (ufw) by default, making this process straightforward. If ufw is not already installed, you can install it using the following command:
sudo pacman -S ufw
Once ufw is installed, you can allow incoming connections on the new SSH port (2222 in our example) with the following command:
sudo ufw allow 2222/tcp
After allowing traffic on the new SSH port, enable ufw to start using these rules:
sudo ufw enable
You can check the status of ufw to ensure that the new rules are applied correctly:
sudo ufw status
Now that the new port is configured and firewall rules are in place, it’s time to restart the SSH service to apply the changes:
sudo systemctl restart sshd
Step 4. Testing the Configuration.
Open a new terminal window on your local machine and try connecting to your Manjaro Linux server using the new SSH port (2222 in our example):
ssh username@your_server_ip -p 2222
username with your username and
your_server_ip with the IP address or hostname of your Manjaro Linux server. You’ll be prompted to enter your password.
Step 5. Troubleshooting Common Issues.
If you encounter connectivity problems or configuration errors during the testing phase, here are some common issues to consider:
Firewall Rules: Ensure that the firewall rules are correctly configured to allow traffic on the new port.
Network Configuration: Verify that your Manjaro Linux server has network connectivity and that there are no network issues causing the problem.
- Syntax Errors: Double-check the modifications you made in the
sshd_configfile. Even a small syntax error can prevent the SSH service from starting.
- Port Conflicts: Make sure the new SSH port you chose is not being used by any other service on your server.
Congratulations! You have successfully changed the SSH port. Thanks for using this tutorial to change the change ssh port on the Manjaro system. For additional help or useful information, we recommend you check the official Manjaro website.