Server Hardening & Tuning

Server Hardening & Tuning

In computing, hardening is usually the process of securing a system by reducing its surface of vulnerability, which is larger when a system performs more functions; in principle a single-function system is more secure than a multipurpose one. Reducing available ways of attack typically includes changing default passwords, the removal of unnecessary software, unnecessary usernames or logins, and the disabling or removal of unnecessary services.

Linux server hardening: 10 easy steps to secure your system

1. Install security patches
Most weaknesses on a system are caused by flaws in software. So upgrading the system and installing software updates. It is fairly easy, limited risk, yet have a great impact. Most Linux distributions have the option to limit what packages you want to upgrade. Especially make sure that your security updates are installed as soon as they come available.

2. Use proper passwords
The main gateway to a system is by logging in as a valid user with the related password of that account. Strong passwords make it more difficult for tools to guess the password and let malicious people walk in via the front door.

3. Bind processes to localhost
Not all daemons have to be available via the network. For example, when running a local instance of MySQL on your web server, it is a viable option to let it only listen on a local socket or bind to localhost (127.0.0.1).

4. Implement a firewall
Only allowed traffic should in an ideal situation reach your system. To achieve this, implement a firewall solution like iptables, or the newer nftables.

When creating a policy for your firewall, consider using a “deny all, allow some” policy. So you deny all traffic by default, then define what kind of traffic you want to allow. This is especially useful for incoming traffic, to prevent sharing services you didn’t intend to share.

5. Keep things clean
Everything installed on a system which doesn’t belong there, can only negatively impact your machine. It will increase your backups (and restore times), it might contain vulnerabilities and will clutter up the system. Same is true for unused user accounts.

6. Secure configurations
Most applications have one or more security measures available to protect against some forms of threats to the software or system. Look at the man page for any options and test these options carefully.

7. Limit access
Only allow access to the machine for authorized users. Does someone really need access or are alternative methods possible to give the user what he or she wants?

8. Monitor your systems
Most intrusions are undetected, due to lack of monitoring. Implement normal system monitoring and implement monitoring on security events. For example, the use of the Linux audit framework increased detection rates of suspected events.

9. Create backups (and test!)
Regular make a backup of system data, to prevent data loss. Even more important, test your backups!

10. Perform system auditing
Lynis (Linux/Unix auditing tool) screenshot
Screenshot of a Linux server security audit performed with Lynis.
Use a tool like Lynis to perform a regular audit of your system and perform further hardening steps.

Lynis runs on almost all Unix or Linux based systems and only requires a normal shell and root permissions.

It will scan the system and perform an in-depth security audit and explain what can be done to improve the system even further. Best of all, the normal Lynis version is free to use and open source.