Skip to content

Set up SSH keys (and stop using passwords)

Password SSH logins are the thing bots attack hardest. SSH keys replace the password with a cryptographic key pair that can’t be brute-forced — and you stop typing passwords. Set this up once per machine you log in from.

1. Generate a key (on your computer)

Terminal window
ssh-keygen -t ed25519 -C "you@example.com"

Press Enter to accept the default location. Add a passphrase for extra safety. You now have:

  • ~/.ssh/id_ed25519 — private key (never share this)
  • ~/.ssh/id_ed25519.pub — public key (safe to copy to servers)

2. Copy the public key to your server

Easiest:

Terminal window
ssh-copy-id youruser@yourserver

Or manually append the contents of id_ed25519.pub to ~/.ssh/authorized_keys on the server.

Now test — you should log in without a password:

Terminal window
ssh youruser@yourserver

3. Disable password logins (once keys work)

Only after confirming key login works, harden SSH. In /etc/ssh/sshd_config:

PasswordAuthentication no
PermitRootLogin prohibit-password

Then reload: sudo systemctl reload ssh.

⚠️ Keep your current session open while you test a new one. If key login breaks, you can fix it from the still-open session instead of being locked out.

4. Lock it down further

  • Restrict port 22 to your IP with the firewall.
  • Keep fail2ban on as a backstop.
  • Use a different key per device, so you can revoke one without touching the rest.

Bonus: keys unlock safe tooling

SSH keys also power secure remote database access via tunnels and Git deploys from private repos.


Running OrbixPanel? Pair SSH keys with the built-in firewall and fail2ban for a hard-to-crack server. OrbixPanel.com → — the free, self-hosted, AI-powered hosting control panel.