Skip to content
BENIBIX Learn

SSH Key Pair

Infrastructure🔑 SSH & Remote AccessSSH Key Authentication

Also known as SSH Key, SSH Keys, Private Key (SSH), Public Key (SSH), id_ed25519

Two matching keys for SSH. You keep the private one and share the public one.

Think of it like

Think of it like a padlock and its key. You hand out the padlock, and you keep the key.

Example

Lucy makes one key pair on her laptop. She puts the public key on four servers and logs in to all of them with no password.

Why it matters

Keys are far harder to guess than passwords. Most servers should only let keys in.

Definition

An SSH key pair is two matching keys used to log in without a password. The private key stays on your computer and is never shared. The public key is a copy you put on each server. What the private key signs, only the public key can check. So the server knows it is you without ever seeing your secret.

Example code

console
$ ls ~/.ssh
id_ed25519  id_ed25519.pub  known_hosts
The file with .pub is the public key to share. The other one is private and stays here.
The private key stays on the laptop. Only the public half goes to the server.

Common mistake

Sending someone the private key, the file without .pub. Only ever share the .pub file.

Key takeaways

  1. 1
    Private stays home. Never copy it to a server.
  2. 2
    Public goes out. Put it on each server.
  3. 3
    Sign and check. No secret crosses the line.

Compare

Learn it properly