/commands/ssh/ssh-keygen-ed25519
ssh-keygen -t ed25519: generate an SSH key
- 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:
ssh-keygen -t ed25519 -C "you@example.com"Non-interactive, for scripts (-N '' means no passphrase, -f sets the file, -q hides the randomart):
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_keyOutput
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
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
| Option | Effect |
|---|---|
| -t ed25519 | Key type; rsa, ecdsa, ed25519, and ed25519-sk / ecdsa-sk for FIDO hardware keys |
| -C comment | Comment stored in the public key (default user@host) |
| -f file | Output file for the private key; the public key gets .pub appended |
| -N passphrase | Passphrase for the new key ("" for none) |
| -a rounds | KDF rounds protecting the passphrase (default 16; higher is slower to brute-force) |
| -p -f file | Change the passphrase of an existing key |
| -y -f file | Print the public key of a private key |
| -l -f file | Show the fingerprint |
For RSA (servers that do not accept Ed25519), use at least 3072 bits: ssh-keygen -t rsa -b 4096.