What Is an SSH Key?

Related Content

Want to keep learning?

Subscribe to SSL.com’s newsletter, stay informed and secure.

Logging into a remote server with just a password works until someone guesses it, phishes it, or runs it through a brute-force script. An SSH key removes that risk by replacing the password with a cryptographic key pair that is effectively impossible to fake.

SSH (Secure Shell) is the protocol administrators and developers use to log into remote servers, move files, and run commands over an encrypted connection. An SSH key is the credential that protocol relies on instead of, or alongside, a password: a mathematically linked pair of files, one public and one private, that together prove who you are without ever sending a secret across the network.

How SSH keys work

An SSH key pair consists of two files:

  • A private key, which stays on your local machine and is never shared.

  • A public key, which you copy to any server you want to access.

When you connect, the server uses the public key to issue a cryptographic challenge that only the matching private key can answer. Your machine solves the challenge locally and sends back proof, not the key itself. The server checks that proof against the public key it already has on file and grants access. The private key never travels across the network, which is what makes this approach fundamentally more resistant to interception than a password.

This is the same public-key cryptography behind SSL/TLS certificates and most of modern PKI: a key pair where one half authenticates and the other verifies, and the private half never needs to leave the device that holds it.

Why use SSH keys instead of passwords

  • Resistant to brute-force and credential-stuffing attacks. A password only has to be guessed or leaked once. A properly generated SSH private key is not something an attacker can feasibly reconstruct from the public key.

  • No shared secret to intercept. The private key never crosses the network, so there is nothing for an attacker on the wire to capture, unlike a password typed over a compromised connection.

  • Supports automation. Scripts, CI/CD pipelines, and cron jobs can authenticate without a human typing a password, using a dedicated key scoped to one task.

  • Revocable per device. Lose a laptop? Remove that one public key from the server’s authorized list instead of resetting a password everyone else also uses.

Types of SSH keys

SSH supports a handful of key algorithms, and the choice affects both security and performance:

  • ED25519: the current recommended default. Shorter keys, faster signing, and resistant to the implementation mistakes that have affected older algorithms.

  • RSA: the long-standing standard, still widely supported. 4096-bit RSA keys remain secure, though they are larger and slower to generate and use than ED25519.

  • ECDSA: elliptic-curve based, smaller and faster than RSA, less commonly recommended today than ED25519.

Most current servers and clients support all three. ED25519 is the right default unless a specific system requires otherwise.

How to generate an SSH key

On Linux or macOS, generate a new key pair from a terminal:

ssh-keygen -t ed25519

This creates two files: a private key (id_ed25519) and a public key (id_ed25519.pub). Set a passphrase when prompted. The passphrase encrypts the private key file itself, so a stolen laptop does not hand over a usable credential along with it.

To put the public key on a server, use ssh-copy-id:

ssh-copy-id user@server_address

Or copy the contents of the .pub file manually into the server’s ~/.ssh/authorized_keys file.

Once the public key is in place, the server can be configured to disable password logins entirely. For the full hardening sequence, including disabling root login, restricting algorithms, and adding logging, see SSL.com’s guide to securing your SSH configuration.

SSH keys vs. SSL/TLS certificates

Both rely on public-key cryptography, and both use a key pair to prove identity without transmitting a secret, but they solve different problems. An SSH key is a bare key pair you generate yourself and manually place on each server you trust. It authenticates a person or a machine to one specific system, and nothing vouches for it beyond the fact that you put it there.

An SSL/TLS certificate adds a third party to that picture: a Certificate Authority signs the public key and binds it to a verified identity, such as a domain or an organization, that any browser or client can check without having met you before. An SSH key answers “is this the same key I trusted last time,” while a certificate answers “has a trusted third party verified who holds this key.” Managing SSH keys across dozens or hundreds of servers runs into the same lifecycle challenge certificate management already addresses: knowing which keys exist, who holds them, and when to revoke one.

Key takeaways

An SSH key pair replaces a password with something far harder to compromise: a private key that never leaves your machine, and a public key that only confirms access; it never grants it by itself. Generate one with ssh-keygen -t ed25519, copy the public half to the server with ssh-copy-id, and turn off password logins once it is working.

Still have questions about how SSH keys work, which type to use, and how to generate one? Contact our team below:


Stay Informed and Secure

SSL.com is a global leader in cybersecurity, PKI and digital certificates. Sign up to receive the latest industry news, tips, and product announcements from SSL.com.

We’d love your feedback

Take our survey and let us know your thoughts on your recent purchase.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognizing you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

For more information read our Cookie and privacy statement.

3rd Party Cookies

This website uses Google Analytics & Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping these cookies enabled helps us to improve our website.

Show details