SSH Hardening
foundations
Migration in progress.
api.legendary-arena.comand PostgreSQL are moving from Render to a self-hosted DigitalOcean Ubuntu host behind Cloudflare. Render remains rollback-ready until decommission phase.
SSH Hardening
Lock remote access to key-only operator login, disable root SSH, and verify access continuity before closing old sessions.
Summary
This page owns infra/scripts/05-user-and-ssh.ps1, which enforces:
- non-root operator account with sudo
PermitRootLogin noPasswordAuthentication no- sshd config validation and reload
Safety sequence
Always keep at least two active SSH sessions open during changes.
- Open session A and session B as
operator. - Run the script in session A.
- Start a new session C to confirm fresh login works.
- Only then close session A/B.
Execute
sudo pwsh -File infra/scripts/05-user-and-ssh.ps1
Optional username override:
sudo OPERATOR_USER=operator pwsh -File infra/scripts/05-user-and-ssh.ps1
Verification
# confirm config directives
sudo grep -E '^(PermitRootLogin|PasswordAuthentication)' /etc/ssh/sshd_config.d/99-la-hardening.conf
# verify sshd config is valid
sudo sshd -t
# verify service health
sudo systemctl status ssh --no-pager
Expected values:
PermitRootLogin noPasswordAuthentication nosshd -texits zero
Mechanics
The script writes a managed drop-in file at /etc/ssh/sshd_config.d/99-la-hardening.conf instead of editing distro defaults inline. This keeps changes explicit, idempotent, and easy to audit.
Failure and rollback
If new login fails after running the script:
- Stay on an existing open SSH session.
- Restore previous file from backup under
/etc/ssh/sshd_config.d/if created. - Re-run
sudo sshd -t. - Reload SSH service and test a new login again.
References
- Plan section 4.1 (
ssh-hardening.mdstub) - Plan section 5.1 (Access hardening safety sequence)