Skip to content
BENIBIX Learn

ssh-keygen

Infrastructure🔑 SSH & Remote AccessSSH Key Authentication

Also known as ssh-keygen Command, Generate SSH Key, ssh-keygen -t ed25519

The command that makes a new SSH key pair on your computer.

Think of it like

Think of it like a key cutter in a shop. You ask, and it cuts you a new key and its lock.

Example

Jack gets a new laptop. He runs ssh-keygen once, sets a passphrase, and has a fresh key pair in his .ssh folder.

Why it matters

Every key login starts here. Making a key takes a few seconds.

Definition

ssh-keygen is the command that makes a new SSH key pair. It asks where to save the keys and for a passphrase. It writes the private key and a .pub file beside it. Current OpenSSH makes an Ed25519 key by default, a short and strong kind. The same command can also remove an old line from known_hosts.

Example code

console
$ ssh-keygen -t ed25519 -C "jack@laptop"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/jack/.ssh/id_ed25519):
Ask for an Ed25519 key with a label. Press Enter to keep the usual place.
ssh-keygen makes both keys at once, in the .ssh folder on the laptop.

Common mistake

Running it again and saying yes to overwrite. The old key is gone, and every server that trusted it locks you out.

Key takeaways

  1. 1
    Makes the pair. Private file and .pub file.
  2. 2
    Ed25519 by default. Short and strong.
  3. 3
    Never overwrite. Old servers still want the old key.

Learn it properly