# SSH Key Pair

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

**Field:** Infrastructure  
**Category:** SSH & Remote Access  
**Also known as:** SSH Key, SSH Keys, Private Key (SSH), Public Key (SSH), id_ed25519

## Think of it like

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

## 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

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.

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [ssh-keygen](https://learn.benibix.com/term/infrastructure/ssh-keygen)
- [SSH Public Key Authentication](https://learn.benibix.com/term/infrastructure/public-key-authentication)
- [authorized_keys](https://learn.benibix.com/term/infrastructure/authorized-keys)
- [SSH Key Passphrase](https://learn.benibix.com/term/infrastructure/ssh-key-passphrase)
- [Secure Shell (SSH)](https://learn.benibix.com/term/infrastructure/ssh)

## Told apart from

- [SSH Host Key vs SSH Key Pair](https://learn.benibix.com/compare/host-key-vs-ssh-key-pair): People think the host key is their own SSH key, and it is not. The host key belongs to the server. It proves to your laptop that it reached the real server, and its copy lives in known_hosts. Your key pair belongs to you. It proves to the server who you are, and its public half lives in authorized_keys.

## Taught in

- [SSH Keys and ssh-keygen](https://learn.benibix.com/learn/infrastructure-ssh/ssh-keys-and-ssh-keygen): SSH, 3/9

![A key pair made by ssh-keygen. The private key stays on the laptop in ~/.ssh/id_ed25519, locked with a passphrase, and ssh-agent holds it open for the day. A copy of the public key sits on the server in ~/.ssh/authorized_keys. At login the server sends a challenge, the laptop signs it with the private key, and the server checks the signature with the public key.](https://learn.benibix.com/diagrams/inf3-ssh-keys.svg)

---

Source: https://learn.benibix.com/term/infrastructure/ssh-key-pair
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
