Part of Datorkirurgen AB – IT experts across Sweden

Hardening Linux for businesses: SSH, firewall, SELinux, updates, crypto policies and logging. Linux Service secures your servers across Sweden.

Why every server needs hardening

A newly installed Linux server is not insecure, but it is built to work for as many people as possible. In other words, it has services, ports and settings that your particular server may not need. Hardening Linux is about removing what is not needed and tightening what remains. Every closed door is a door that an attacker cannot use. Therefore, we start all operations assignments with a review of the security.

The work follows a fixed list based on recognised guidelines, for example the CIS Benchmarks. In addition, we update the list when new threats appear. However, we adapt the list to your business. A web server needs different settings from a database server or a workstation. Moreover, we document every change, so that you know what has been done and why. In this way, security becomes understandable and not just a black box.

Basic list for hardening Linux servers in businesses
Basic list for hardening Linux servers in businesses. This is how Linux Service, part of Datorkirurgen AB, works for businesses in Gothenburg and Malmö.

SSH: the most important door

SSH is the way in for administrators, and therefore also for attackers. We switch off sign-in with passwords and only allow keys. Root may not sign in directly; instead, administrators sign in with their own accounts and use sudo. In addition, we restrict which users may sign in at all. If possible, we only allow SSH from the office address or via a VPN.

We also install Fail2ban, which blocks addresses that try to guess their way in. Moreover, it considerably reduces the noise in the logs. On our own web servers, we also restrict the administration pages to a fixed address. When someone needs to work from another location, we open access temporarily. See also the warning about post-quantum SSH, which many people have started to see.

Hardening Linux: SSH settings that only allow keys
Hardening Linux: SSH settings that only allow keys. Do you need help with Linux? Linux Service helps you in Uppsala, on site or remotely.

Firewall, SELinux and crypto policies

First and foremost, the firewall should only let in what is needed. On the Red Hat family, we use firewalld, and on Debian and Ubuntu we use nftables or UFW. In addition, we look at outgoing traffic, since a hacked server often tries to contact an external server. If the server does not need to connect outwards on arbitrary ports, we close that too.

SELinux and AppArmor restrict what each program may do, even if it is hacked. We leave them switched on and instead correct the rules that need adjusting. Crypto policies control which protocols and algorithms the server accepts. On the Red Hat family and Amazon Linux, the crypto-policies package is available, and there we choose a modern level. As a result, we switch off old protocols such as TLS 1.0 everywhere.

Updating the SELinux policy and crypto policies on a Linux server
Updating the SELinux policy and crypto policies on a Linux server. A real update from our operations, where selinux-policy and crypto-policies receive new versions.

Updates and vulnerabilities

Most intrusions exploit vulnerabilities that already have a fix. Therefore, updates are the single most important security measure. We install security fixes automatically and larger updates in planned maintenance windows. In addition, we follow security advisories for the programs you use. When a serious vulnerability becomes known, we act the same day.

We also check software that does not come from the distribution, for example WordPress plugins, Python packages and Java libraries. Such components are often forgotten, but they are at least as important. More about how we update Amazon Linux 2023 without surprises.

Downloading security updates with new crypto policies and certificates
Downloading security updates with new crypto policies and certificates. Linux Service, part of Datorkirurgen AB, helps businesses in Nacka and Södermalm with servers, scripts and databases.

Logging, monitoring and testing

Hardening without logging, on the other hand, is like a lock without an alarm. We collect logs from all servers in a central location, so that an attacker cannot delete the traces locally. After that, we set up alerts for suspicious events, for example new administrator accounts or sign-ins from unknown countries. In addition, the auditd tool can log changes to sensitive files.

Finally, we test the result. We run an audit with tools such as Lynis and, if needed, an external scan from Kali Linux. We compare the result with the list from the start. Everything that remains ends up in an action plan with priority and a schedule. We go through the plan together with you, so that everyone understands why each point matters. After that, we carry out the actions in the order that gives the most protection for the least work.

Workflow for hardening Linux servers from review to test
Workflow for hardening Linux servers from review to test. This is how Linux Service, part of Datorkirurgen AB, works for businesses in Stockholm.

Contact Linux Service about hardening Linux

Linux Service is part of Datorkirurgen AB, which carries out security audits and forensic investigations for businesses. We harden servers on all major distributions, both in your own data centres and in the cloud. The guidelines we work from are available from CIS.

Therefore, contact us for a review of your servers. We start with a quick check and propose actions in order of priority. We work remotely or on site in Stockholm. Moreover, we can follow up the security every month.

Frequently asked questions about hardening Linux

Questions about hardening Linux

Hardening Linux: SSH and firewall

More about updates and monitoring

Website developed by Datorkirurgen AB · Privacy policy