Skip to content
Log In Sign Up info@muvcloud.com

The Short Answer

An SSH key is a pair of matching files that lets you log in to a server without typing a password. The private key stays on your own device and is never shared. The public key is copied into ~/.ssh/authorized_keys of the account you log in to on the server. When you connect, the server checks that your device holds a private key matching one of the keys in that file.

~/.ssh/id_ed25519        private key: keep it secret
~/.ssh/id_ed25519.pub    public key: safe to copy to servers

SSH itself, the protocol that carries the session, is explained in what is SSH.

How Key Login Works

  1. Your SSH client connects and tells the server which public key it wants to use.
  2. The server looks for that public key in the account's authorized_keys file.
  3. The client signs data that belongs to this one session with the private key.
  4. The server checks the signature with the public key. If it is valid, you are logged in.

The private key never leaves your device, and the signature is valid only for this session, so a recorded connection gives an attacker nothing to reuse. A password, by contrast, can be guessed. This is why key login is the standard for servers, and why many administrators then disable SSH password authentication.

Key Types

TypeWhen to use it
ed25519First choice for new keys
rsa, 3072 bits or moreOld systems without Ed25519
ecdsaWorks, rarely needed
dsaRemoved; do not use

Ed25519 keys are short, fast, and strong. Since OpenSSH 9.5, ssh-keygen without options creates an Ed25519 key; older releases create a 3072-bit RSA key. Name the type to be sure. OpenSSH 10.0 removed DSA support completely.

Create a Key and Put It on a Server

On your own computer:

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

Accept the default file name and set a passphrase. The -C label is stored at the end of the public key. Then copy the public key to the server:

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

The full steps are in how to generate SSH keys and ssh-copy-id. One line in authorized_keys looks like this:

ssh-ed25519 AAAA...rest-of-the-key... laptop-2026

On the server, ~/.ssh and authorized_keys should belong to the user, with modes 700 and 600. With the default StrictModes yes, the SSH server ignores the file if other users can write to it or to the directories above it; see Permission denied (publickey).

Passphrase and Agent

A passphrase encrypts the private key file, so a copied or stolen file is useless without it. An SSH agent holds the unlocked key in memory, so you type the passphrase once per session:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add -l

Most desktop sessions start an agent for you. Agent forwarding and the other options are covered in ssh-agent.

Fingerprints

A fingerprint is a short hash of a public key, used to compare keys without reading the whole line:

ssh-keygen -lf ~/.ssh/id_ed25519.pub

The output shows the key size, a fingerprint that starts with SHA256:, the label, and the type. Run the same command on the server against ~/.ssh/authorized_keys to see which keys have access, one line per key.

Host Keys Are a Different Thing

Your key proves who you are. The server's host key proves that you reached the right server: your client stores it in ~/.ssh/known_hosts on the first connection and warns if it changes. Read host key verification failed before you remove the old entry.

Good Habits and Lost Keys

  • One key per device: create a separate key on each computer you use, so you can revoke one device without touching the others.
  • Never copy the private key to a server, a chat, or a repository. Only the .pub file goes anywhere.
  • One public key, many places: the same public key can go on every server you manage and on services such as GitHub.
  • Short names for servers: keep the user, port, and key file of each server in the SSH config file.

If a device is lost or stolen, log in with another key or through your provider's console and delete that device's line, recognizable by its label, from authorized_keys on every server. A lost private key cannot be recovered: create a new pair and add the new public key.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations