How to Secure Your Linux Server

Linux servers are a great, cost-effective way for businesses to store and share data. Linux is open-source, so it provides plenty of resources and community cooperation. However, that also brings security concerns.

If you’re going to run a Linux server, you have to know how to secure it properly. This article will provide you with all you need to know to secure your Linux server, regardless of what Linux distro you’re running.

Here are the steps for securing a Linux server

1. Update the Server

Updating the operating system and all applications is the first step to securing your Linux server. Having the latest patches will ensure that you have the most recent security fixes. You should regularly check to ensure everything is up-to-date.

To update all local repositories and software, you can either use:

  • The Update Manager – which will search for updates and notify you if any are available. All distros that have a GUI have a way of updating it via a GUI.
  • The Linux terminal – use the terminal to enter commands that will update your system.

2. Create a Privileged Account

Most administrators avoid using root when logging into their servers, as one typo or wrong command can destroy the server. Instead, it’s best to create a new user account with Sudo privileges. These privileges will allow users to use root commands without putting the server at risk. Check the LiquidWeb tutorial for more info on how to create and manage sudo privileges. 

3. Protect Your Server With a Password or SSH Key

After setting up an account, it’s crucial to protect it with a form of authentication to prevent unauthorized users from gaining access. For this, you have two options:


Setting passwords for your Linux system and the accounts you use with it can protect you from many security risks. You can easily set and edit the system password via the terminal. If you have trouble remembering passwords for your accounts, keep them all in one place with a Linux password manager.

The passwords you use have to be strong and regularly rotated for extra protection. A password manager can come in handy for this as well.


Setting up an SSH key will allow you to access your server securely without entering a password. You can generate the key via the terminal and assign it to your server. To learn how to do that, click here.

4. Install a Firewall

To protect your server from online threats, you have to install a firewall. The open-source nature of Linux allows for quite a few options for a firewall solution. It’s best to do your own research and determine the best choice for your needs.

Some firewalls can block all incoming traffic from your network but allow outgoing traffic. This means you can access the internet without allowing other applications or networks to reach your server. You can modify who is allowed on your server based on your needs. The most common usage is to block everything except ports 80, 443, and your SSH port if you’re using your server to host websites.

5. Limit Network-Facing Services

All Linux versions come with a few network-facing services. You are also able to install extra services for added functionalities. The problem with this is if you enable and install these services, and you barely use them, they unnecessarily leave you more vulnerable to attacks.

Most of these services, especially those that come pre-installed with your Linux distro, are perfectly safe to use, but you should still disable those you aren’t using. To see all running services, use the ss command. From there, you can see which ones you don’t use and proceed to delete them.

6. Don’t Go Overboard With Packages

Since Linux is open-source, there’s no limit to how many third-party packages you can install. But, while packages can significantly boost server capabilities, they also bring security concerns. That’s why it’s best only to install packages that you’ll use regularly.

7. Set-up 2FA

You can set up 2FA (Two-factor Authentication) for your server by installing an authentication package. This way, anyone trying to access the server will have to provide an extra layer of authentication aside from the password. The extra layer can come in the form of a QR code or a secret code that will be displayed on a different device (like a phone) via authentication software.

Final Thoughts on securing a Linux server

Linux is on the safer side as far as servers go. Still, with the current cyber environment, you can never be too safe. It’s best to take the security of your server into your own hands and work to minimize the risk of potential breaches.

By following the steps and tips laid out in this article, you’ll be well on your way to making your Linux server a lot more secure. These tips are just the tip of the iceberg, securing a Linux server is a much more tedious task and takes a lot of knowledge and experiencee to do it properly. You should do more research and take all the extra steps you can to properly secure your server.

Leave a comment

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