Skip to content

Latest commit

 

History

History
91 lines (82 loc) · 6.04 KB

security.md

File metadata and controls

91 lines (82 loc) · 6.04 KB

Security

Overview of the security and secrets cheat sheets, with a hardening checklist for a homelab or small self-hosted environment. The aim is layered defence: keep secrets out of Git, put identity in one place, block abuse automatically, and scan what you build.

Sheets in This Section

SHEET USE IT FOR
SOPS and age Encrypt secrets (.env, YAML) so they can live in Git
Vault and OpenBao Central secret store with policies, dynamic credentials (Vault / OpenBao)
GPG Keys, signing, encryption, Git commit signing, backups
authentik Self-hosted SSO, OIDC and forward-auth
Keycloak Self-hosted SSO, OIDC, SAML and federation
CrowdSec Log-driven intrusion prevention with community blocklists and bouncers
fail2ban Simple host-based log-driven IP bans
Secret Scanning gitleaks, TruffleHog, GitHub push protection
Container Scanning Trivy, Grype and Syft for images and IaC
Lynis and auditd Host hardening audit and Linux audit logging

Related Sheets Elsewhere

SHEET USE IT FOR
OpenSSL Certificates, CSRs, key conversion
OpenSSH Cheat-Sheet SSH keys, hardening sshd_config
Bitwarden Cheat-Sheet Password manager and CLI
Passbolt Self-hosted team password manager (Docker, cake passbolt, backup)
1Password CLI Cheat-Sheet op read, run and inject secrets
pass Cheat-Sheet GPG and git password store
gopass Cheat-Sheet Team password store with recipients and OTP
LastPass CLI Cheat-Sheet lpass login, show, export
TLS (Transport Layer Security) TLS configuration
SSL Security Cheat-Sheet TLS security testing and settings
UFW (uncomplicated firewall) Simple host firewall
IPTables Low-level firewall rules
Tailscale Private mesh VPN instead of exposing ports
Teleport Short-lived certificates for SSH and Kubernetes access
Cert-Manager Automated certificates in Kubernetes

Choosing Tools

NEED PICK
Secrets in a Git repo (GitOps, .env) SOPS and age
Many apps and services fetching secrets at runtime, dynamic credentials Vault and OpenBao
One login for all apps, small setup authentik
Enterprise features, SAML, large ecosystem Keycloak
Ban brute-force on one host, minimal setup fail2ban
Shared threat intel, multiple hosts or proxies CrowdSec

Hardening Checklist

Access

  • SSH: key-only auth, PasswordAuthentication no, PermitRootLogin no, non-default users (OpenSSH Cheat-Sheet)
  • Prefer a VPN or mesh (Tailscale, WireGuard) over exposing admin ports to the internet
  • Single sign-on with MFA for web UIs (authentik or Keycloak); passkeys or TOTP for everything else
  • Unique passwords in a manager (Bitwarden Cheat-Sheet); no shared admin accounts
  • Least privilege: scoped API tokens, Vault policies, Kubernetes RBAC (Kubernetes)

Network

Secrets

  • No plaintext secrets in Git: SOPS and age or Vault and OpenBao; .env in .gitignore
  • Secret scanning in pre-commit and CI (Secret Scanning); GitHub push protection on
  • Rotate on a schedule and immediately after any leak; revoke before cleaning history
  • Back up age/GPG/Vault unseal keys offline, separately from the data (GPG)

Hosts and Containers

  • Unattended security updates on (unattended-upgrades); reboot for kernel fixes
  • Pin image versions or digests, update via Renovate, scan images (Container Scanning)
  • Run as non-root, read_only, cap_drop: [ALL], no-new-privileges (Docker-Compose)
  • Don't mount /var/run/docker.sock into containers unless required (it is root on the host)
  • Minimal installed packages and services; ss -tulpn to audit listening ports
  • Audit logs shipped off-host and watched (Prometheus, Grafana)

Recovery

  • Tested, encrypted, off-site backups (3-2-1) and a documented restore procedure
  • Break-glass admin account stored offline; recovery codes saved
  • Know how to revoke: SSH keys, GPG subkeys, API tokens, certificates

Quick Audit Commands

COMMAND DESCRIPTION
ss -tulpn Listening ports and owning processes
sudo ufw status verbose Firewall state
sudo journalctl -u ssh --since "1 day ago" | grep -i "failed" Recent SSH failures
last -n 20 / lastb -n 20 Recent logins / failed logins
sudo sshd -T | grep -E "passwordauthentication|permitrootlogin" Effective SSH settings
apt list --upgradable Pending updates
docker ps --format '{{.Names}}\t{{.Ports}}' Which containers publish ports
nmap -sV <HOST> External view of open services (NMap; only scan hosts you own)