Automating Security Compliance: A DevOps Guide to GDPR-Ready Infrastructure in Norway
If you think the GDPR panic ended on May 25, 2018, you likely haven't dealt with a rigorous Data Processing Agreement (DPA) audit recently. For CTOs and Systems Architects operating in Norway, the landscape has shifted from "getting compliant" to "staying compliant without burning out."
Here is the brutal truth: Manual security hardening is dead. If you are manually editing /etc/ssh/sshd_config on production servers, you have already lost. In a recent migration for a FinTech client based in Oslo, we faced a requirement to prove the integrity of 200+ nodes every 24 hours. A spreadsheet of "checked boxes" doesn't cut it for Datatilsynet (The Norwegian Data Protection Authority).
This guide explores how to automate security compliance using Infrastructure as Code (IaC) principles, ensuring your stack is audit-ready by default. We will focus on tools available right now in late 2019, specifically targeting RHEL 8/CentOS 7 and Debian 10 environments.
The Sovereignty First Approach
Before touching a single line of code, we must address the infrastructure layer. With the US CLOUD Act causing friction against European privacy standards, relying solely on US-based hyperscalers introduces legal ambiguity. While Privacy Shield is currently in place, the legal ground is shaking.
For critical Norwegian data, physical residency is the only zero-risk strategy. This is where CoolVDS fits into the architecture. Unlike container-based VPS providers where kernel sharing can lead to side-channel vulnerabilities, we utilize strict KVM virtualization. This provides the hardware-level isolation required for strict compliance, ensuring your memory space is yours alone. Furthermore, our datacenter footprint in Norway guarantees low latency to NIX (Norwegian Internet Exchange) and keeps data strictly under Norwegian jurisdiction.
Automating the Baseline: CIS Benchmarks
The Center for Internet Security (CIS) provides the gold standard for server hardening. However, a CIS PDF is 400 pages long. We don't read PDFs; we run code.
We use Ansible to enforce these states. Idempotency is key—running the script 100 times should result in the same secure state, never breaking the system.
1. Hardening SSH Configuration
The default SSH configuration on most Linux distributions favors compatibility over security. We need to disable root login, enforce key-based authentication, and remove weak ciphers.
Here is an Ansible task snippet to enforce a hardened SSH state:
- name: Secure SSHD Configuration
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
validate: 'sshd -t -f %s'
with_items:
- { regexp: '^PermitRootLogin', line: 'PermitRootLogin no' }
- { regexp: '^PasswordAuthentication', line: 'PasswordAuthentication no' }
- { regexp: '^X11Forwarding', line: 'X11Forwarding no' }
- { regexp: '^MaxAuthTries', line: 'MaxAuthTries 3' }
- { regexp: '^Protocol', line: 'Protocol 2' }
notify: restart sshd
2. Kernel Runtime Parameters (sysctl)
Network stack hardening protects against IP spoofing and Man-in-the-Middle attacks. These settings should be applied via sysctl.conf.
# /etc/sysctl.d/99-security.conf
# IP Spoofing protection
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# Ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable source packet routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
# Log Martians
net.ipv4.conf.all.log_martians = 1
Pro Tip: Applying these settings on a live high-traffic server can sometimes disrupt legitimate traffic if your internal routing is messy. Test these in a staging environment first. CoolVDS allows you to spin up hourly-billed instances for exactly this type of destructive testing.
Continuous Compliance Auditing with OpenSCAP
Hardening is not a one-time event; it's a process. Configuration drift occurs when a developer temporarily opens a port or changes a permission and forgets to revert it. To combat this, we use OpenSCAP (Security Content Automation Protocol).
OpenSCAP can scan your system against the specific profile (e.g., PCI-DSS, STIG, or GDPR) and report failures.
Installation (RHEL/CentOS 7):
yum install scap-security-guide openscap-scanner
Running a Compliance Scan:
oscap xccdf eval \
--profile xccdf_org.ssgproject.content_profile_pci-dss \
--results scan-results.xml \
--report report.html \
/usr/share/xml/scap/ssg/content/ssg-centos7-ds.xml
This command generates an HTML report showing exactly where your server fails compliance. Integrating this into your CI/CD pipeline (Jenkins or GitLab CI) ensures you never deploy a non-compliant server image.
Data at Rest: The Encryption Performance Tax
GDPR Article 32 explicitly mentions encryption. For a pragmatic CTO, this means Full Disk Encryption (FDE) or, at minimum, encrypted partitions for database storage (/var/lib/mysql).
However, LUKS (Linux Unified Key Setup) encryption adds CPU overhead to every I/O operation. On legacy spinning rust (HDD) or oversold VPS platforms, this kills database performance. You will see iowait skyrocket, and your application latency will suffer.
| Storage Type | Unencrypted Read/Write | LUKS Encrypted Read/Write | Performance Penalty |
|---|---|---|---|
| Standard HDD VPS | 120 MB/s | 85 MB/s | ~30% Drop |
| SATA SSD | 450 MB/s | 380 MB/s | ~15% Drop |
| CoolVDS NVMe | 2500+ MB/s | 2200+ MB/s | Negligible |
This is why we standardized on NVMe storage for all CoolVDS high-performance tiers. The sheer IOPS capability of NVMe absorbs the encryption overhead, making security invisible to the end-user. If you are running MySQL or PostgreSQL with encryption enabled, NVMe is not a luxury; it is a requirement.
File Integrity Monitoring (FIM)
To detect if an attacker has managed to modify system binaries, you need FIM. AIDE (Advanced Intrusion Detection Environment) is the standard open-source tool for this.
Initialize the database:
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
Create a cron job to run a check daily and mail the output to the security team:
# /etc/cron.daily/aide-check
#!/bin/bash
/usr/sbin/aide --check | /bin/mail -s "Daily AIDE Report - $(hostname)" security@yourdomain.no
Conclusion
Compliance in 2019 is about proving control. It requires a shift from manual administration to automated enforcement. By leveraging Ansible for configuration management, OpenSCAP for auditing, and robust hardware for encryption, you turn compliance from a yearly headache into a daily routine.
Don't let legacy infrastructure compromise your security posture. Deploy your hardened stack on a platform built for performance and sovereignty.
Ready to audit-proof your infrastructure? Deploy a high-performance NVMe KVM instance on CoolVDS today and keep your data safe in Norway.