• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Monday, May 12, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Change SSH Port on Arch Linux

in Arch Linux, Linux OS
Changing SSH Port on Arch Linux

Changing the default SSH port on your Arch Linux server can greatly improve security and reduce the risk of unauthorized access. In this guide, we will walk you through the process of how to change SSH port on Arch Linux system.

Table of Contents

  1. Introduction
  2. Backup SSH configuration file
  3. Edit SSH configuration file
  4. Restart the SSH service
  5. Update firewall rules
  6. Test the new SSH port
  7. Troubleshooting
  8. Conclusion

Introduction

Secure Shell (SSH) is a widely used protocol that allows secure remote access to servers and other network devices. By default, SSH listens on port 22. However, changing the default port can help reduce the risk of automated attacks targeting this well-known port number. This tutorial will show you how to change the SSH port on Arch Linux.

How to Change SSH Port on Arch Linux

Backup SSH configuration file

Before making any changes to the SSH configuration file, it is recommended to create a backup. This will allow you to revert to the original settings if something goes wrong. To create a backup, run the following command:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

Edit SSH configuration file on Arch Linux

To change the SSH port, you need to edit the /etc/ssh/sshd_config file. You can use any text editor, such as Vim or Nano, to edit the file. In this example, we will use the Nano text editor:

sudo nano /etc/ssh/sshd_config

Look for the line that starts with #Port 22. Remove the “#” at the beginning of the line and change the port number to the desired value, e.g., 2222:

Port 2222

Save the changes and exit the text editor.

Note: Make sure to choose a port number above 1024 and not already in use by another service. You can use the ss or netstat commands to check for available ports.

Restart the SSH service

After modifying the configuration file, you need to restart the SSH service for the changes to take effect. To restart the SSH service, run the following command:

sudo systemctl restart sshd

Update firewall rules

If you have a firewall enabled on your Arch Linux system, you need to update the firewall rules to allow incoming connections on the new SSH port. In this example, we will assume that you are using the ufw firewall. To update the rules, run the following commands:

sudo ufw delete allow 22/tcp
sudo ufw allow 2222/tcp
sudo ufw reload

Replace 2222 with the new SSH port you have chosen.

Test the new SSH port on Arch Linux

To test the new SSH port, try connecting to your Arch Linux server using the new port number. From a remote machine, run the following command:

ssh -p 2222 your_username@your_server_ip

Replace 2222 with the new SSH port number, and your_username and your_server_ip with the appropriate values for your Arch Linux server.

If everything is configured correctly, you should be able to establish an SSH connection using the new port number.

Troubleshooting

If you encounter any issues while changing the SSH port or connecting to your Arch Linux server, try the following troubleshooting steps:

  1. Double-check the /etc/ssh/sshd_config file for any syntax errors or incorrect port numbers.
  2. Ensure that the SSH service is running by executing sudo systemctl status sshd. If it is not running, try to restart it using sudo systemctl restart sshd.
  3. Verify that your firewall rules have been updated correctly to allow incoming connections on the new SSH port.
  4. Check the logs for any error messages or additional information. The SSH logs can be found in /var/log/auth.log or by running sudo journalctl -u sshd.

If you are still unable to resolve the issue, consider reverting to the original configuration by restoring the backup you created earlier:

sudo cp /etc/ssh/sshd_config.backup /etc/ssh/sshd_config
sudo systemctl restart sshd

Conclusion

In this tutorial, we have shown you how to change the default SSH port on an Arch Linux system. This simple change can help improve the security of your server by reducing the risk of automated attacks targeting the default SSH port. Remember to update your firewall rules and test the new SSH port to ensure that your server remains accessible after making these changes.

For more tutorials on managing Arch Linux, check out these articles:

  • How to Install Git on Arch Linux
  • How to Install Python on Arch Linux
  • How to Install Nginx on Arch Linux
  • How to Set Up Apache Web Server on Arch Linux
ShareTweet
Previous Post

How to Install Git on Arch Linux

Next Post

How to Install Let’s Encrypt SSL on Arch Linux

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

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

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.