Changing the default SSH port on your openSUSE system can help improve security by making it more difficult for unauthorized users to connect to your server. In this tutorial, we will guide you through the process of how to change SSH port in openSUSE system.
Table of Contents:
How to Change SSH Port on openSUSE
- Why change the SSH port?
- Prerequisites
- Update your system
- Edit the SSH configuration file
- Restart the SSH service
- Adjust the firewall settings
- Test the new SSH port
Why change the SSH port?
The default SSH port (22) is a common target for brute-force attacks and port scanning. Changing the port number can help reduce the number of unauthorized connection attempts, making your system more secure.
Prerequisites
Before proceeding, make sure you have the following:
- An openSUSE system with SSH server installed
- Root access to the system
Update your system
Before making any changes, ensure that your system is up to date by running the following command:
zypper update
Edit the SSH configuration file
To change the SSH port, you need to edit the SSH configuration file. You can use any text editor, such as Vim or Nano. If you don’t have Vim installed, follow our guide on How to Install Vim on openSUSE. In this example, we’ll use Vim:
vim /etc/ssh/sshd_config
Look for the following line:
#Port 22
Uncomment the line by removing the ‘#’ symbol and change the port number to your desired value. For example, to set the port to 2222:
Port 2222
Save the file and exit the editor.
Restart the SSH service
To apply the changes, restart the SSH service:
systemctl restart sshd
Adjust the firewall settings
Next, update your firewall settings to allow traffic on the new SSH port. In this example, we will allow traffic on port 2222:
firewall-cmd --permanent --zone=public --add-port=2222/tcp
firewall-cmd --reload
Don’t forget to remove the old SSH port from the firewall:
firewall-cmd --permanent --zone=public --remove-port=22/tcp
firewall-cmd --reload
Test the new SSH port
Finally, test the new SSH port by connecting to your server using the new port number:
ssh user@your_server_ip -p 2222
If the connection is successful, you have successfully changed the SSH port on your openSUSE system.
Conclusion
Changing the default SSH port on openSUSE is a simple yet effective way to enhance your server’s security. By following this tutorial, you have learned how to change the SSH port, update the firewall settings, and test the new port.
Now that you have secured your SSH connection, consider exploring other security measures for your openSUSE server, such as:
- Installing a firewall, like CSF
- Securing your database with MariaDB or MySQL
- Setting up SSL certificates for your web server
Remember that server security is an ongoing process. Keep your system updated, monitor logs, and stay informed about the latest security best practices. By being proactive, you can ensure the safety and integrity of your openSUSE server.