Create an SSH key pair with ssh-keygen (Ed25519)

Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.

LinuxTerminaldevelopersecurityLow risk
Run ssh-keygen -t ed25519 -C "user@machine" and accept the default path to create ~/.ssh/id_ed25519 and id_ed25519.pub.

01Command

Command
$ ssh-keygen -t ed25519 -C "user@machine"

02What it does

The -C comment is just a label (commonly user@host) that helps you tell keys apart later; the tool prompts for an optional passphrase, which is worth setting because it protects the key if the machine is stolen. The .pub file is what you install on servers: ssh-copy-id user@server appends it to the server's ~/.ssh/authorized_keys, or paste it into a Git host's SSH settings. ssh-keygen only creates keys — it does not install them anywhere. For very old servers that lack Ed25519 support, fall back to ssh-keygen -t rsa -b 4096. List your keys with ls ~/.ssh/*.pub.

03Risk

RiskLow risk
RequirementsOpenSSH client; the key pair is written to ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519.pub
!Warning: Never share or commit the private key (id_ed25519) — only the .pub file goes to servers and Git hosts; a leaked private key must be treated as compromised and replaced.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • ssh-keygen(1) — OpenSSH authentication key utility
    man7.org · technical · 2026-09-17
    Evidence: The ssh-keygen man page documents -t to select the key type (including ed25519) and -C to provide a new comment.
  • OpenSSH - ArchWiki
    Arch Linux Wiki · community · 2026-09-17
    Evidence: The ArchWiki OpenSSH page recommends ssh-keygen -t ed25519 for generating Ed25519 keys and describes copying the public key to servers with ssh-copy-id.

Last verified: 2026-09-17 · Category: Security & Privacy

06Related solutions