Lesson 2 of 14 · 18m
SSH as the Control Plane
~/.ssh/config, ed25519 keys, ProxyJump instead of agent forwarding, and -L tunnels that make open ports unnecessary.
SSH on a self-hosted box is not a login method — it's the transport for almost everything you do. rsync moves files over it, git push deploys over it, -L tunnels reach databases over it, ssh -J chains hosts over it. Operators who treat it as "the way I get a shell" end up opening ports that a tunnel would have made unnecessary.
~/.ssh/config is the real control plane
Host tower
HostName 203.0.113.10
User deploy
IdentityFile ~/.ssh/id_ed25519_tower
IdentitiesOnly yesNow ssh tower does everything. IdentitiesOnly yes matters more than it looks: without it, ssh offers every key in your agent in sequence, and a server with MaxAuthTries 6 can lock you out with the right key sitting fourth in line.
Key types, briefly: ssh-keygen -t ed25519 is the default you want — short keys, fast signatures, no NIST curves. RSA 4096 survives for ancient peers; note that OpenSSH 8.8 (2021) disabled the ssh-rsa SHA-1 signature scheme by default, and a client that needs -o PubkeyAcceptedAlgorithms=+ssh-rsa to log in is a client telling you to retire that box. Hardware tokens get ed25519-sk, which requires a FIDO2 touch — stolen key file, still useless.
ForwardAgent is the trap, ProxyJump is the tool
ssh -A (or ForwardAgent yes) exports your agent socket to the remote as /tmp/ssh-XXXX/agent.PID. Your private key never leaves your laptop — but while you're connected, root on that remote host can point SSH_AUTH_SOCK at your socket and authenticate as you, to anywhere your key is trusted. On a box you fully control and nobody else roots, it's convenient. Everywhere else it's an exported signing oracle.
The correct primitive is ProxyJump: ssh -J bastion internal chains the TCP connection through the bastion while your client authenticates to the target directly — the bastion sees an encrypted stream it cannot impersonate. In config: ProxyJump bastion.
Tunnels replace open ports
ssh -L 5433:127.0.0.1:5432 deploy@towerWhile that session lives, localhost:5433 on your laptop is the server's 127.0.0.1:5432 — encrypted, authenticated, and gone when you disconnect. Postgres, Redis, a one-off admin UI, a metrics endpoint: reach all of them this way and none of them ever need a published port or a firewall exception. -R does the inverse (expose your laptop's port to the remote), -D 1080 makes a SOCKS proxy out of the whole connection for browser debugging.
Two files worth not confusing: authorized_keys is who may log in; known_hosts is which servers you trust. That first-connection fingerprint prompt is trust-on-first-use — StrictHostKeyChecking accept-new takes the convenience without taking the silence when a key changes. When you rebuild a box, ssh-keygen -R tower clears the stale entry; a changed host key is the MITM alarm working as designed, not an annoyance to reflexively bypass.
Key material quality is not theoretical: in 2008 Debian shipped an OpenSSL RNG seeded by process ID (CVE-2008-0166), which made every key generated on those systems predictable; Debian carried an ssh-vulnkey blacklist for years afterward. mosh earns a mention for flaky links — UDP, local echo, survives roaming between Wi-Fi and LTE — and when a connection misbehaves, ssh -vvv narrates exactly which key was offered and which config line was read; it answers "why didn't it work" faster than guessing.
Field notes
MaxAuthTries 3,LoginGraceTime 20s, andAllowUsers deployinsshd_configshrink the window further;sshd -Tdumps the effective config when includes get creative.ssh -o Foo=baroverrides anything in config for one shot — use it instead of editing the file for experiments.scpis deprecated-ish in upstream OpenSSH; reach forrsyncorsftpand be happier.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Self-Hosting Vaultwarden Without Trusting the Defaults
Vaultwarden gives you a Bitwarden-compatible password server in one container and about ten minutes. The defaults that make that possible leave org creation open, audit logging off, accounts on PBKDF2, and a rate limiter that trusts a header anyone can set.
What You Can Self-Host on Oracle Cloud Free Tier (2026)
What actually fits on Oracle Cloud free tier after the June 2026 cut: Ghost, Vaultwarden, Syncthing, monitoring, and a small AI model, sized in real RAM.
The Complete Self-Hosted AI Stack for 2026
Building a local AI server is more than installing Ollama. This guide builds a full production AI stack with Open WebUI, LiteLLM, Qdrant, Traefik, and Langfuse — what each component does, why it's needed, and three complete Docker Compose configurations for beginners, power users, and small teams.
Self-Host OpenClaw: VPS Setup to Production (2026)
Self-host OpenClaw from zero to production. Server provisioning, SSH lockdown, Docker, reverse proxy, Fail2ban, performance tuning, and full backup strategy in one guide.