Skip to content

/commands/ssh/ssh-keygen-ed25519

ssh-keygen -t ed25519: generate an SSH key

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · OpenSSH_10.5p1updated
tool
OpenSSH
versions
OpenSSH 6.5+
os
linux, macos, windows

ssh-keygen -t ed25519 -C "you@example.com" creates a new Ed25519 key pair: the private key in ~/.ssh/id_ed25519 and the public key in ~/.ssh/id_ed25519.pub. It asks for a file name and a passphrase. Copy the public key (.pub) to the server's ~/.ssh/authorized_keys, for example with ssh-copy-id. Ed25519 keys are short, fast, and supported by OpenSSH 6.5 and later.

Generate a key

Interactive, with the default path and a passphrase prompt:

bash
ssh-keygen -t ed25519 -C "you@example.com"

Non-interactive, for scripts (-N '' means no passphrase, -f sets the file, -q hides the randomart):

bash
ssh-keygen -q -t ed25519 -N '' -C 'ci@example.org' -f deploy_key
ls deploy_key*
ssh-keygen -l -f deploy_key.pub | awk '{print $1, $3, $4}'
cut -d' ' -f1,3 deploy_key.pub
head -1 deploy_key

Output

deploy_key
deploy_key.pub
256 ci@example.org (ED25519)
ssh-ed25519 ci@example.org
-----BEGIN OPENSSH PRIVATE KEY-----

ssh-keygen -l prints the key size, the SHA256 fingerprint (hidden here, because it is random), the comment and the type.

Install it on a server

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server.example.com
# without ssh-copy-id (for example on Windows):
cat ~/.ssh/id_ed25519.pub | ssh user@server.example.com 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

Useful options

OptionEffect
-t ed25519Key type; rsa, ecdsa, ed25519, and ed25519-sk / ecdsa-sk for FIDO hardware keys
-C commentComment stored in the public key (default user@host)
-f fileOutput file for the private key; the public key gets .pub appended
-N passphrasePassphrase for the new key ("" for none)
-a roundsKDF rounds protecting the passphrase (default 16; higher is slower to brute-force)
-p -f fileChange the passphrase of an existing key
-y -f filePrint the public key of a private key
-l -f fileShow the fingerprint

For RSA (servers that do not accept Ed25519), use at least 3072 bits: ssh-keygen -t rsa -b 4096.

Sources