Hardening the host¶
Host setup¶
The steps below assume Debian or Ubuntu; Fedora equivalents are noted. Example files live
in deploy/.
Base system¶
sudo apt install unattended-upgrades needrestart
sudo dpkg-reconfigure -plow unattended-upgrades # Fedora: dnf install dnf-automatic, enable dnf-automatic-install.timer
- SSH with keys only:
PasswordAuthentication no,PermitRootLogin noin/etc/ssh/sshd_config.d/10-hardening.conf, thensystemctl reload ssh. - Time sync must work (TOTP and certificate validity depend on it):
timedatectlshowsSystem clock synchronized: yes. - The
limdm-server.serviceunit already runs sandboxed (no capabilities, read only system, private tmp, syscall filter). Check withsystemd-analyze security limdm-server; do not loosen it with drop-ins. - File modes:
/etc/limdm-server/server.envroot:limdm 0640,/var/lib/limdm-server/calimdm:limdm 0700, key file0600.
Firewall with ufw¶
sudo apt install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw limit from 198.51.100.0/24 to any port 22 proto tcp # SSH only from your admin network
sudo ufw allow 80/tcp # ACME HTTP challenge, redirect to HTTPS
sudo ufw allow 443/tcp # console (Caddy)
sudo ufw allow 8444/tcp # agents, mTLS
sudo ufw enable
sudo ufw status verbose
PostgreSQL (5432) and the console listener (8080, loopback) must not be reachable from outside; with the rules above they are not. If your devices only connect through a VPN, restrict 8444 to the VPN range instead of opening it to everyone:
Fedora, RHEL rebuilds and SUSE with firewalld:
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --permanent --add-port=8444/tcp
sudo firewall-cmd --reload
Plain nftables: tcp dport { 80, 443, 8444 } accept in the input chain with policy drop.
Caddy¶
deploy/Caddyfile proxies the console, writes a JSON access log for
fail2ban and CrowdSec, limits request bodies and hides the server banner. The server itself
sets HSTS, CSP and the other security headers.
To allow the console only from your networks while devices can still fetch the install
script and your identity provider can reach SCIM, uncomment the @outside block in the
Caddyfile.
fail2ban¶
LiMDM locks an account after 5 wrong passwords and rate limits sign ins per address. fail2ban additionally blocks the source address at the firewall. The server logs every failed sign in (local and OIDC) and every rejected enrollment with the client address, for example:
Install the filters and jails from deploy/fail2ban:
sudo apt install fail2ban
sudo cp deploy/fail2ban/filter.d/limdm*.conf /etc/fail2ban/filter.d/
sudo cp deploy/fail2ban/jail.d/limdm.local /etc/fail2ban/jail.d/
# put your office and VPN egress addresses into ignoreip in limdm.local
sudo fail2ban-regex systemd-journal /etc/fail2ban/filter.d/limdm.conf # check the filter against your journal
sudo systemctl restart fail2ban
sudo fail2ban-client status limdm
limdm: 5 failures in 10 minutes ban the address for an hour (longer for repeat offenders) on 80 and 443.limdm-tls: 30 failed TLS handshakes on 8444 in 10 minutes ban for 30 minutes. Agents whose certificate expired also fail the handshake; keep the threshold high and your NAT addresses inignoreip.- fail2ban uses ufw automatically when
banaction = ufwis set injail.local; the default nftables or iptables action works too. - Add the stock
sshdjail if SSH is reachable from the internet.
CrowdSec¶
CrowdSec reads the same events and shares decisions with its community blocklist. Files:
deploy/crowdsec.
# add the CrowdSec package repository first (docs.crowdsec.net, "Linux" install guide)
sudo apt install crowdsec crowdsec-firewall-bouncer-nftables
sudo cscli collections install crowdsecurity/linux crowdsecurity/sshd crowdsecurity/caddy crowdsecurity/http-cve
sudo cp deploy/crowdsec/acquis.d/limdm.yaml /etc/crowdsec/acquis.d/
sudo cp deploy/crowdsec/parsers/s01-parse/limdm-logs.yaml /etc/crowdsec/parsers/s01-parse/
sudo cp deploy/crowdsec/scenarios/limdm-bf.yaml /etc/crowdsec/scenarios/
sudo cp deploy/crowdsec/parsers/s02-enrich/limdm-console-whitelist.yaml /etc/crowdsec/parsers/s02-enrich/
sudo systemctl reload crowdsec
sudo cscli explain --type syslog --log 'Nov 25 08:00:00 mdm limdm-server[1]: {"level":"WARN","msg":"local login failed","user":"x","remote":"203.0.113.7"}'
sudo cscli decisions list
limdm/limdm-bf: more than 5 failed sign ins or enrollments within a few minutes.limdm/limdm-tls-scan: bursts of failed TLS handshakes on the agent port.limdm/console-whitelist: the console loads many icons and API responses at once; without itcrowdsecurity/http-crawl-non_staticsbans admins. Only successful (200) responses on console image paths and/api/v1/are ignored, failed requests still count.- For Caddy access logs add an acquisition for
/var/log/caddy/limdm-access.logwithtype: caddy;crowdsecurity/caddythen detects scanners and known exploits. - Whitelist your office and VPN egress addresses with a postoverflow whitelist
(
crowdsecurity/whitelists), so IT is never blocked.
Use either fail2ban or CrowdSec for the same service, not both, to keep bans traceable.
PostgreSQL¶
- Listen on the unix socket only:
listen_addresses = ''inpostgresql.confwhen the database is local. - Peer authentication for
limdm, no password:local limdm limdm peerinpg_hba.conf. - Remote databases: TLS with a certificate the server verifies (
sslmode=verify-full), a dedicated role that owns only thelimdmdatabase.
Backups and keys¶
Back up the database, the device CA and LIMDM_SESSION_KEY (Operations).
Encrypt the CA and the session key and keep them apart from the database dump; test a
restore regularly.
Checklist¶
- HTTPS certificate valid, port 80 only redirects
- only 22 (restricted), 80, 443 and 8444 open; 5432 and 8080 closed from outside
-
server.env0640root:limdm, CA directory 0700limdm - OIDC configured, local login disabled or one break glass account
- fail2ban or CrowdSec active,
ignoreipor whitelist set - unattended security updates on the server
- backups of database, CA and session key, restore tested (restore test)
- audit log exported or monitored, compliance webhook set
Server process hardening¶
Firewall (ufw, firewalld, nftables), fail2ban and CrowdSec rules for failed sign ins and agent
port scans, Caddy, PostgreSQL and a checklist: Host setup.
Failed local and OIDC sign ins and rejected enrollments are logged with the client address
(local login failed, oidc login failed, enroll rejected).