Security · 31 October 2026 · 3 min read

SSH Keys Explained: Ed25519 vs RSA, Setup and Safe Login

By

How SSH key pairs work, Ed25519 vs RSA, where authorized_keys lives, which file permissions SSH insists on, passphrases, and how to disable password login safely.

SSH Keys Explained: Ed25519 vs RSA, Setup and Safe Login

Logging in to a server with a password works, but it is the weakest part of most small server setups: bots try common passwords against every public SSH port all day long. SSH keys replace the password with a key pair that cannot be guessed. Setting them up takes ten minutes, and most problems come from a few details: the wrong file, the wrong permissions, or locking yourself out. If you are on a machine without ssh-keygen, the SSH key generator creates a pair in your browser.

Public key, private key

A key pair has two halves:

  • The private key (for example ~/.ssh/id_ed25519) stays on your computer. Anyone who has this file can log in as you, so it never goes into email, chat, Git or a shared drive.
  • The public key (id_ed25519.pub, a single line starting with ssh-ed25519) goes on the servers and services you want to access. It is safe to share; it can only verify, not log in.

When you connect, the server sends a challenge, your SSH client signs it with the private key, and the server checks the signature with the public key. The private key itself never travels over the network.

Ed25519 or RSA?

For new keys, use Ed25519. Keys are short, signing is fast, and every OpenSSH server from the last decade supports it, as do GitHub, GitLab and Bitbucket. Create one with:

ssh-keygen -t ed25519 -C "laptop-2026"

The comment after -C is just a label. Use something that tells you which device the key belongs to, so you know which line to delete when that laptop is retired.

Choose RSA only for old systems, network devices or appliances that do not accept Ed25519. Use at least 3072 bits, which is the default of current ssh-keygen, or 4096. Old 1024-bit keys should be replaced. You may also see errors with very old RSA setups on new servers, because OpenSSH has disabled the old SHA-1 based ssh-rsa signature type by default. The key is fine; the client and server need to be recent enough to use SHA-2 signatures. For TLS, JWT or other non-SSH uses, the RSA key generator creates keys in PEM format.

authorized_keys and permissions

On the server, public keys are listed one per line in ~/.ssh/authorized_keys of the user you log in as. The easiest way to add yours is:

ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server

If key login still asks for a password, the cause is usually permissions. SSH refuses to use keys when files are writable by others:

  • ~/.ssh must be 700 (owner only).
  • ~/.ssh/authorized_keys should be 600.
  • Your private key on the client must be 600, or SSH refuses to load it with an “UNPROTECTED PRIVATE KEY FILE” warning.
  • The home directory must not be writable by group or others.
  • The files must be owned by the user, not by root, a common mistake when they were created with sudo.

The server log (journalctl -u ssh or /var/log/auth.log) usually states the exact reason, and ssh -v user@server shows which keys the client tried.

Passphrases and the agent

A passphrase encrypts the private key file, so a stolen laptop backup does not give away server access. Add or change one at any time with ssh-keygen -p -f ~/.ssh/id_ed25519. Keys created in the browser tool come without a passphrase, so run this command right after saving them.

To avoid typing it on every connection, use ssh-agent: it holds the decrypted key in memory for your session. macOS can store the passphrase in the Keychain, and Windows has an OpenSSH agent service.

Turning off password login, without locking yourself out

  1. Confirm that key login works, in a new terminal, while your current session stays open.
  2. In /etc/ssh/sshd_config set PasswordAuthentication no, KbdInteractiveAuthentication no and PermitRootLogin prohibit-password (or no).
  3. Check the files in /etc/ssh/sshd_config.d/. On Ubuntu and other systems, they are included at the top, and for most settings the first value found wins. A cloud image file that says PasswordAuthentication yes silently overrides your change.
  4. Test the configuration with sudo sshd -t, then reload: sudo systemctl reload ssh (the service is called sshd on Red Hat based systems).
  5. Try a password login from another terminal. It should be refused. Only then close your original session.

Our take

One key per device, never one key copied to every laptop. When a device is lost or a person leaves, you delete one line from authorized_keys and nothing else changes. Generate production keys with ssh-keygen on the machine that will use them, protect them with a passphrase, and keep the server console or provider’s web console handy whenever you change SSH settings. That console has rescued more administrators than any other single feature.

Anthony ParkerNetwork and systems engineer

Anthony has worked in IT for more than 17 years: office and field networks, servers, telephony, user support and security patching in international organisations. He writes about networking, security, developer tools and calculators.