What are Steps to Secure a Linux Server? (2024)

Nov 15, 2023 1:45:00 PM


Dmitry Tkachuk

Imunify Security, Product Owner

  • Web Server Security
  • Advice

What are Steps to Secure a Linux Server?

What are Steps to Secure a Linux Server? (2)

Overall, the Linux operating system is very secure, but the applications, tools, and configurations administrators install create risks to the environment. Linux powers 75% of the internet, and it’s installed on 6.64 million web servers. Because Linux powers critical systems around the globe, it’s imperative that administrators take the necessary steps to harden the operating system’s security. Although Linux is inherently secure, several configurations and strategies help harden its defenses and reduce the risk of a compromise. This article goes over the following questions:

  1. Why security in Linux is important
  2. How to secure Linux servers?
    1. Install only necessary packages
    2. Use an alternative to root
    3. Enforce password security
    4. Secure SSH
    5. Block booting from external devices
    6. Install and validate the server’s firewall
    7. Update software regularly
  3. Why is Operating System Security Hardening Required?
  4. Conclusion

What are Steps to Secure a Linux Server? (3)

Why Security in Linux is Important

Linux security is important because Linux is so popular with web servers, attackers write custom scripts targeting the operating system to scan for known vulnerabilities and exploit them. For example, web server response headers return critical information about the host, including the server operating system, unless administrators follow the OWASP suggestion to hide this information.

With the Linux distribution and version in hand, attackers can then launch targeted attacks against a web server. If the Linux version has known vulnerabilities, an attacker can either download pre-made scripts or craft an exploit of their own. In other words, a combination of returning information about the Linux version running on the server and running outdated software leaves the web server open to exploits. Kernel vulnerabilities are serious threats to the stability of the web, and they can have critical consequences. Vulnerabilities such as Dirty Cow and SACK Panic gave attackers elevated privileges or a denial-of-service (DoS), and these issues were just two examples that could lead to critical data breaches or downtime.

Kernel vulnerabilities aren’t the only source of vulnerabilities. Third-party applications also introduce vulnerabilities and give attackers the opportunity to steal data. Heartbleed was discovered in 2014 and continues to be a problem for older unpatched Linux-based servers allowing threat actors to steal data in a buffer underflow exploit. The vulnerability was found in several older versions of OpenSSL, commonly used as an encryption library on Linux servers.

What are Steps to Secure a Linux Server? (4)

How to Secure Linux Servers?

With numerous vulnerabilities open to attackers, it’s critical for administrators to be aware of their attack surface and the risks involved with default settings on Linux and any third-party applications that could cause issues. You can’t decrease risk by 100%, but you can take the right precautions and perform hardening on the operating system regardless of the distribution installed.

Here are a few tips for hardening security in Linux:

  • Install only necessary packages. It’s tempting to install every package you think might be useful in the future, but the more packages you install on a server, the more risk you add. For example, if you don’t need to host DNS, then you shouldn’t install DNS packages or leave its service ports open (53).
  • Use an alternative to root. Although root is a target for any threat actor, it’s especially risky on public-facing servers. Instead of leaving the root user active, you can create a new user and elevate its privileges on the server. After elevating privileges, you can reduce them on root or disable the account.
  • Enforce password security. Password length and complexity defend against brute-force dictionary attacks. Passwords for critical accounts should be at least 12 characters and rotated frequently. Many administrators know the importance of password complexity, but they don’t have a rotation schedule. Passwords should be rotated frequently to reduce the window an attacker has to compromise a system should your password get leaked or brute-forced.
  • Secure SSH. Gaining access to SSH could give an attacker full control over the server, so securing it should be a priority. You can make several changes on the server to ensure that SSH is secure. Here are a few ways to secure SSH:

Generate cryptographic keys and upload them to your server using the following commands:

$ ssh-keygen -t rsa

$ ssh-copy-id <username>@ip_address

Using cryptographic keys instead of passwords makes it harder for a threat actor to use brute-force attacks on credentials.

After you generate and upload cryptographic keys, you can disable password authentication in the /etc/ssh/sshd_config file. The following two directives should be configured to “no” in the configuration file:

PasswordAuthentication no

PermitRootLogin no

  • Block booting from external devices. Most administrators think of virtual attacks, but physical attacks are possible too. Piggybacking (or tailgating) is one method used to gain physical access to servers. Booting servers with a USB device provides attackers with numerous ways to run their own malware or steal data. To disable booting from a USB device, run:

# chmod 000 /media/

Note: This does not fully secure a system when the attacker has physical access to it.

  • Install and validate the server’s firewall. A firewall will help stop both incoming and outgoing attacks. The firewall on Linux will close off popular ports used in exploits. To install the firewall, use the following command:

$ sudo apt install ufw

After you install the firewall, use the following command to enable it:

$ sudo ufw enable

You can see the services enabled and running your server by using the following command:

$ sudo ufw status

  • Update software regularly. Outdated software is one of the most common vulnerabilities responsible for system compromise. Ransomware attacks are high on the list of risks, especially in recent years, and they account for 46.4% of the breaches. Outdated software can lead to successful ransomware attacks, data breaches, remote code execution, server compromise, and many other risks that could result in revenue and reputation loss for the organization. By updating software regularly, you apply critical security patches to your server software that remediates the vulnerability.

What are Steps to Secure a Linux Server? (5)

Why is Operating System Security Hardening Required?

The Linux operating system is secure, but the installation process configures it with default settings. Attackers are aware of each distribution’s default settings, and some settings make the server vulnerable to exploits. For example, the default settings for SSH weaken security on the system, which is why it’s important to harden security on a server that runs SSH.

With the default configurations in place, attackers know exactly how your server is set up and runs. The harder you make it for attackers to figure out how a server is configured, the more layers of security you add to your environment. Another example is disabling or reducing root privileges. Attackers target the root user account since it’s the well-known highest privileged user. When it’s reconfigured, you put a wrench in their works and force them to discover the alternative account.

What are Steps to Secure a Linux Server? (6)

Conclusion

Hardening the operating system is important for the security of your server and safeguarding user data. To stay ahead of attackers, configure Linux with custom configurations that make it more difficult for attackers to scan the system and exploit common vulnerabilities to add layers of security to your server. You can’t ensure 100% security on any system, but hardening the operating system greatly reduces risks associated with cyber-attacks. Learn how to take advantage of Linux server security with Imunify360 and discover how it is different from other security tools.

What are Steps to Secure a Linux Server? (7)

Recommended articles:

  • 17 ways to improve your cPanel security
  • What are Antivirus False Positives and What to Do About Them?
  • Shared Hosting Security Guide for 2021
  • WordPress Security Ultimate Guide for 2023
  • ModSecurity Rules 2023: How to Guide
  • Proactive vs. Reactive Security: 5 Tips for Proactive Cyber Security
  • 15 security tips for Linux VPS Hosting
  • Security made easy with Imunify360
  • Top 15 Plesk Server Security Best Practices to Protect Your Website
  • Top 10 Web Hosting Security Best Practices
  • What Are Your First Three Steps When Securing a Linux Server?
  • What are steps to secure a Linux server?
  • How to keep your website secure in 2021
  • Ultimate Guide for DirectAdmin Security from Security Experts

What are Steps to Secure a Linux Server?

Nov 15, 2023 1:45:00 PM

Dmitry Tkachuk

  • Web Server Security
  • Advice

What are Steps to Secure a Linux Server? (9)

Overall, the Linux operating system is very secure, but the applications, tools, and configurations administrators install create risks to the environment. Linux powers 75% of the internet, and it’s installed on 6.64 million web servers. Because Linux powers critical systems around the globe, it’s imperative that administrators take the necessary steps to harden the operating system’s security. Although Linux is inherently secure, several configurations and strategies help harden its defenses and reduce the risk of a compromise. This article goes over the following questions:

  1. Why security in Linux is important
  2. How to secure Linux servers?
    1. Install only necessary packages
    2. Use an alternative to root
    3. Enforce password security
    4. Secure SSH
    5. Block booting from external devices
    6. Install and validate the server’s firewall
    7. Update software regularly
  3. Why is Operating System Security Hardening Required?
  4. Conclusion

What are Steps to Secure a Linux Server? (10)

Why Security in Linux is Important

Linux security is important because Linux is so popular with web servers, attackers write custom scripts targeting the operating system to scan for known vulnerabilities and exploit them. For example, web server response headers return critical information about the host, including the server operating system, unless administrators follow the OWASP suggestion to hide this information.

With the Linux distribution and version in hand, attackers can then launch targeted attacks against a web server. If the Linux version has known vulnerabilities, an attacker can either download pre-made scripts or craft an exploit of their own. In other words, a combination of returning information about the Linux version running on the server and running outdated software leaves the web server open to exploits. Kernel vulnerabilities are serious threats to the stability of the web, and they can have critical consequences. Vulnerabilities such as Dirty Cow and SACK Panic gave attackers elevated privileges or a denial-of-service (DoS), and these issues were just two examples that could lead to critical data breaches or downtime.

Kernel vulnerabilities aren’t the only source of vulnerabilities. Third-party applications also introduce vulnerabilities and give attackers the opportunity to steal data. Heartbleed was discovered in 2014 and continues to be a problem for older unpatched Linux-based servers allowing threat actors to steal data in a buffer underflow exploit. The vulnerability was found in several older versions of OpenSSL, commonly used as an encryption library on Linux servers.

What are Steps to Secure a Linux Server? (11)

How to Secure Linux Servers?

With numerous vulnerabilities open to attackers, it’s critical for administrators to be aware of their attack surface and the risks involved with default settings on Linux and any third-party applications that could cause issues. You can’t decrease risk by 100%, but you can take the right precautions and perform hardening on the operating system regardless of the distribution installed.

Here are a few tips for hardening security in Linux:

  • Install only necessary packages. It’s tempting to install every package you think might be useful in the future, but the more packages you install on a server, the more risk you add. For example, if you don’t need to host DNS, then you shouldn’t install DNS packages or leave its service ports open (53).
  • Use an alternative to root. Although root is a target for any threat actor, it’s especially risky on public-facing servers. Instead of leaving the root user active, you can create a new user and elevate its privileges on the server. After elevating privileges, you can reduce them on root or disable the account.
  • Enforce password security. Password length and complexity defend against brute-force dictionary attacks. Passwords for critical accounts should be at least 12 characters and rotated frequently. Many administrators know the importance of password complexity, but they don’t have a rotation schedule. Passwords should be rotated frequently to reduce the window an attacker has to compromise a system should your password get leaked or brute-forced.
  • Secure SSH. Gaining access to SSH could give an attacker full control over the server, so securing it should be a priority. You can make several changes on the server to ensure that SSH is secure. Here are a few ways to secure SSH:

Generate cryptographic keys and upload them to your server using the following commands:

$ ssh-keygen -t rsa

$ ssh-copy-id <username>@ip_address

Using cryptographic keys instead of passwords makes it harder for a threat actor to use brute-force attacks on credentials.

After you generate and upload cryptographic keys, you can disable password authentication in the /etc/ssh/sshd_config file. The following two directives should be configured to “no” in the configuration file:

PasswordAuthentication no

PermitRootLogin no

  • Block booting from external devices. Most administrators think of virtual attacks, but physical attacks are possible too. Piggybacking (or tailgating) is one method used to gain physical access to servers. Booting servers with a USB device provides attackers with numerous ways to run their own malware or steal data. To disable booting from a USB device, run:

# chmod 000 /media/

Note: This does not fully secure a system when the attacker has physical access to it.

  • Install and validate the server’s firewall. A firewall will help stop both incoming and outgoing attacks. The firewall on Linux will close off popular ports used in exploits. To install the firewall, use the following command:

$ sudo apt install ufw

After you install the firewall, use the following command to enable it:

$ sudo ufw enable

You can see the services enabled and running your server by using the following command:

$ sudo ufw status

  • Update software regularly. Outdated software is one of the most common vulnerabilities responsible for system compromise. Ransomware attacks are high on the list of risks, especially in recent years, and they account for 46.4% of the breaches. Outdated software can lead to successful ransomware attacks, data breaches, remote code execution, server compromise, and many other risks that could result in revenue and reputation loss for the organization. By updating software regularly, you apply critical security patches to your server software that remediates the vulnerability.

What are Steps to Secure a Linux Server? (12)

Why is Operating System Security Hardening Required?

The Linux operating system is secure, but the installation process configures it with default settings. Attackers are aware of each distribution’s default settings, and some settings make the server vulnerable to exploits. For example, the default settings for SSH weaken security on the system, which is why it’s important to harden security on a server that runs SSH.

With the default configurations in place, attackers know exactly how your server is set up and runs. The harder you make it for attackers to figure out how a server is configured, the more layers of security you add to your environment. Another example is disabling or reducing root privileges. Attackers target the root user account since it’s the well-known highest privileged user. When it’s reconfigured, you put a wrench in their works and force them to discover the alternative account.

What are Steps to Secure a Linux Server? (13)

Conclusion

Hardening the operating system is important for the security of your server and safeguarding user data. To stay ahead of attackers, configure Linux with custom configurations that make it more difficult for attackers to scan the system and exploit common vulnerabilities to add layers of security to your server. You can’t ensure 100% security on any system, but hardening the operating system greatly reduces risks associated with cyber-attacks. Learn how to take advantage of Linux server security with Imunify360 and discover how it is different from other security tools.

What are Steps to Secure a Linux Server? (14)

Recommended articles:

  • 17 ways to improve your cPanel security
  • What are Antivirus False Positives and What to Do About Them?
  • Shared Hosting Security Guide for 2021
  • WordPress Security Ultimate Guide for 2023
  • ModSecurity Rules 2023: How to Guide
  • Proactive vs. Reactive Security: 5 Tips for Proactive Cyber Security
  • 15 security tips for Linux VPS Hosting
  • Security made easy with Imunify360
  • Top 15 Plesk Server Security Best Practices to Protect Your Website
  • Top 10 Web Hosting Security Best Practices
  • What Are Your First Three Steps When Securing a Linux Server?
  • What are steps to secure a Linux server?
  • How to keep your website secure in 2021
  • Ultimate Guide for DirectAdmin Security from Security Experts

What are Steps to Secure a Linux Server? (2024)

FAQs

What are Steps to Secure a Linux Server? ›

A centralized authentication service is crucial for Linux security as it allows sysadmins to enforce password policies and manage user accounts in a secure and scalable way. It makes monitoring and auditing authentication easier, reduces the risk of lost login credentials, and ensures consistent user data.

How do you secure a Linux server? ›

What are Steps to Secure a Linux Server?
  1. Install only necessary packages.
  2. Use an alternative to root.
  3. Enforce password security.
  4. Secure SSH.
  5. Block booting from external devices.
  6. Install and validate the server's firewall.
  7. Update software regularly.
Nov 15, 2023

What are the steps to secure a server? ›

How to secure a Windows server?
  1. Use local firewall rules. ...
  2. Think twice before sharing any data: ...
  3. Enforce a strong password policy. ...
  4. Create individual administrative accounts: ...
  5. SQL server instances: ...
  6. Windows updates: ...
  7. Always have a backup plan: ...
  8. Code it right:

How will security be implemented in Linux systems? ›

A centralized authentication service is crucial for Linux security as it allows sysadmins to enforce password policies and manage user accounts in a secure and scalable way. It makes monitoring and auditing authentication easier, reduces the risk of lost login credentials, and ensures consistent user data.

How do you securely remote access a Linux server? ›

How can you secure remote access to a Linux server?
  1. Use SSH keys. Be the first to add your personal experience.
  2. Use a VPN. Be the first to add your personal experience.
  3. Use a firewall. Be the first to add your personal experience.
  4. Use fail2ban. Be the first to add your personal experience.
  5. Use MFA. ...
  6. Here's what else to consider.
Feb 29, 2024

What is the most secure Linux server? ›

Best Secure Linux Comparison Table
DistributionUser FriendlinessTop 3 Security Applications
Parrot Security OSHighMetasploit Framework, Nmap, Aircrack-ng
Kali LinuxModerateNmap, Metasploit Framework, Wireshark
Qubes OSLowXen, FirewallVM, Whonix
BlackArch LinuxLowMetasploit, Wireshark, SQLmap
2 more rows
Jul 15, 2024

How do I secure my hosted server? ›

  1. Install and Configure a Web Application Firewall.
  2. Distributed Denial-of-Service Attack Protection.
  3. Use SFTP Instead of FTP.
  4. Back-Up Data on Servers.
  5. Use Whitelisting for Maintenance IPs.
  6. SSL/TLS Connections.
  7. Antivirus and Antimalware Protections.
  8. Remove Unused Applications Not Used for Hosting.
Nov 7, 2023

How do you physically secure a server? ›

To ensure server physical security, start with a secure location, restrict access with biometric or card-based systems, employ surveillance, control environmental factors, implement access logs, secure hardware with locks, regularly audit access permissions, and have a comprehensive disaster recovery plan.

How do you know if a server is secure? ›

A secure URL should begin with “https” rather than “http.” The “s” in “https” stands for secure, which indicates that the site is using a Secure Sockets Layer (SSL) Certificate. This lets you know that all your communication and data is encrypted as it passes from your browser to the website's server.

How to establish a secure server? ›

How to Establish a Secure Connection to a Server: 5 Common Methods
  1. SSH. One method for establishing a secure connection is using Secure Shell (SSH). ...
  2. VPN. Another method is using a Virtual Private Network (VPN) that creates an encrypted tunnel between the user's device and the server. ...
  3. HTTPS. ...
  4. SSL/TLS. ...
  5. FTPS or SFTP.
Apr 20, 2023

How to make Linux more secure? ›

So, if you'd like to learn some of the most important security tips for Linux system hardening, this guide is for you.
  1. Enable Strong Authentication. ...
  2. Create an SSH Key Pair. ...
  3. Keep the System Up to Date. ...
  4. Remove Unnecessary Software. ...
  5. Disable Root Login. ...
  6. Check and Close Open Ports. ...
  7. Enable a Firewall. ...
  8. Security Audits Are Important.
Sep 27, 2023

How to check Linux server security? ›

The easiest way to check if this is the case is to connect to your Linux server via SSH and run:
  1. w.
  2. If you run the “w” command, you can see the IP address of other connected users via the 'FROM' field. ...
  3. whois 8.8.8.8.
  4. who -u.
  5. last.
  6. last gremlin.
Mar 4, 2024

Does Linux have a security system? ›

It has several built-in security mechanisms, such as firewalls, firmware verification, Linux Kernel Lockdown, and mandatory access control systems like SELinux and AppArmor.

How can I secure my Linux server? ›

Implement a Password or SSH Key

Passwords and SSH keys are also popular ways to secure a Linux server. This is an important step after setting up a new account with privileges and administrative access; otherwise, anyone can access that profile and make changes to your server without your agreement.

How to secure SSH in Linux? ›

  1. Utilize SSH keys for authentication instead of passwords. SSH keys provide stronger security and are less susceptible to brute-force attacks.
  2. Disable password-based authentication if possible. This can be done by setting PasswordAuthentication no in the SSH configuration file (/etc/ssh/sshd_config).
Apr 12, 2024

How do I manage a Linux server remotely? ›

Connect from MacOS, Windows, and Linux using the command line.
  1. Open the Command Execution Interface. To open the command execution interface, operations on each operating system may be slightly different. ...
  2. Connect to Linux servers. ...
  3. Download SSH clients. ...
  4. Connect to Linux Servers.

How do I restrict access to a Linux server? ›

Here are various ways to achieve this:
  1. File and Directory Permissions. ...
  2. Ownership and Group Management. ...
  3. Access Control Lists (ACLs) ...
  4. User and Group Limits with PAM and /etc/security/limits. ...
  5. SELinux (Security-Enhanced Linux) ...
  6. Firewall Configuration. ...
  7. TCP Wrappers. ...
  8. SSH Server Configuration.
Dec 10, 2023

How do I make my Ubuntu server more secure? ›

Ubuntu Server Hardening Guide
  1. Ensure Only Root Has UID of 0. Accounts that have a UID set to 0 have the highest access to a system. ...
  2. Check for Accounts With Empty Passwords. ...
  3. Lock Accounts. ...
  4. Adding New User Accounts. ...
  5. Sudo Configuration. ...
  6. Iptables. ...
  7. Disable Root Login. ...
  8. Allow Specific Users.

How to maintain a Linux server? ›

Regular maintenance tasks for Linux servers include:
  1. Disk Space Management: Monitoring and managing disk usage is essential to prevent storage capacity issues. ...
  2. Log File Management: Log files provide valuable insights into system activities and potential issues.

How do I check my Linux server security? ›

How To Check if Your Linux Server Has Been Hacked
  1. Check Active Logins. If a bad actor has hacked your server, they might still be signed in. ...
  2. Check Previous Logins. ...
  3. Check Previous Commands. ...
  4. Check the Most Intensive Processes. ...
  5. Check All System Processes. ...
  6. Check Network Processes. ...
  7. Terminate Unauthorized Processes.
Mar 4, 2024

Top Articles
Nav vs Credit Sesame: Credit Building and Monitoring Comparison | Nav
How to Get the Most Euros for Your Home Currency When in Amsterdam
Jack Doherty Lpsg
Ron Martin Realty Cam
Davita Internet
Skyward Houston County
Combat level
How To Do A Springboard Attack In Wwe 2K22
Tesla Supercharger La Crosse Photos
Ingles Weekly Ad Lilburn Ga
Directions To 401 East Chestnut Street Louisville Kentucky
A Fashion Lover's Guide To Copenhagen
Toonily The Carry
Declan Mining Co Coupon
Sitcoms Online Message Board
2021 Lexus IS for sale - Richardson, TX - craigslist
Available Training - Acadis® Portal
N2O4 Lewis Structure & Characteristics (13 Complete Facts)
Yakimacraigslist
Whitefish Bay Calendar
Big Lots Weekly Advertisem*nt
Company History - Horizon NJ Health
Morse Road Bmv Hours
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Academy Sports Meridian Ms
Knock At The Cabin Showtimes Near Alamo Drafthouse Raleigh
Which Sentence is Punctuated Correctly?
Churchill Downs Racing Entries
Restaurants In Shelby Montana
The Creator Showtimes Near Baxter Avenue Theatres
Dl.high Stakes Sweeps Download
Ancestors The Humankind Odyssey Wikia
Grove City Craigslist Pets
Metro By T Mobile Sign In
Lil Durk's Brother DThang Killed in Harvey, Illinois, ME Confirms
Selfservice Bright Lending
42 Manufacturing jobs in Grayling
Myfxbook Historical Data
Gt500 Forums
Ezpawn Online Payment
Luvsquad-Links
Amy Zais Obituary
Lightfoot 247
Barber Gym Quantico Hours
25100 N 104Th Way
1Tamilmv.kids
Strange World Showtimes Near Atlas Cinemas Great Lakes Stadium 16
Ciara Rose Scalia-Hirschman
Diablo Spawns Blox Fruits
Grandma's Portuguese Sweet Bread Recipe Made from Scratch
Costco Tire Promo Code Michelin 2022
Round Yellow Adderall
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 6618

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.