🔐 SSH
My SSH notes, from the first key to a hardened server.
🧭 In this order
- Generate an SSH key pair: Ed25519, a passphrase, and what the options mean
- The SSH config file: short names for your servers, keys per host, jump hosts
- Permissions for SSH files: why SSH refuses a key that others can read
- Harden an SSH server: keys only, no root login, a firewall and fail2ban
- Login email notifications with PAM: a mail every time someone logs in
Old network gear: Connect to a Cisco switch with SSH (“no matching key exchange method found”).
⚡ Quick reference
ssh-keygen -t ed25519 -C "me@laptop" # a new key pair
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server # put your public key on a server
ssh-keygen -lf ~/.ssh/id_ed25519.pub # the fingerprint of your key
ssh-keygen -R server # forget an old host key (after a reinstall)
ssh -J jumphost user@internal-server # via a jump host
ssh -L 8080:localhost:80 user@server # forward a local port to the server
🔗 Go deeper
- How an SSH connection is built: the key exchange, the host key and your key, step by step, with the mathematics
- YubiKey 4 — SSH with FIDO2 and YubiKey 5 — OpenPGP, GPG and SSH: your SSH key in hardware