Build the ssh-keygen command
Pick the key you want — Ed25519, a key on a FIDO security key, ECDSA or RSA — and this page writes the exact ssh-keygen command, explains every flag in it, and gives you the ~/.ssh/config block that uses the key. For macOS and Linux, every Ed25519, ECDSA and RSA choice it offers has been run through ssh-keygen 10.2 and the key that came out checked against what the page says. Security-key commands were checked only as far as ssh-keygen accepting their options: without the token, no key can be made.
It never asks for your passphrase. ssh-keygen asks for it in your terminal, which is the only place it should be typed.
Choose the key
The commands
- Install OpenSSH from Homebrew — the
ssh-keygenandsshthat come with macOS cannot use a security key:brew install openssh - Make sure
~/.sshexists:mkdir -p -m 700 ~/.ssh - Create the key:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519Copied.
- Add this to
~/.ssh/config:Fill in a host above to get a block for
~/.ssh/config.First, this line goes at the very top of the file, above every
HostandMatchline.UseKeychainis Apple’s own option; placed first, this line makes any other OpenSSH — Homebrew’s, or the same file on Linux — skip it instead of refusing the whole file. Lower down, it would only apply inside the block above it. If the file already starts with anIgnoreUnknownline, addUseKeychainto that line after a comma instead: only the first one counts.IgnoreUnknown UseKeychainCopied.
Then add this block anywhere below it, for example at the end:
Copied.
- Put the public key on the server:
ssh-copy-id -i ~/.ssh/id_ed25519.pub server.example.com - Check its fingerprint — the string sshd writes to the server’s log when this key signs in, and the one the fingerprint tool prints:
ssh-keygen -lf ~/.ssh/id_ed25519.pub
What each flag does
-t ed25519— the key type. Ed25519 is what ssh-keygen makes by default since OpenSSH 9.5: a 68-character public key, fast signatures, nothing to tune.-f— where the private key goes. The public key is written next to it with .pub added.
Worth knowing
- If the file already exists, ssh-keygen asks before overwriting it. Answer n unless you mean to replace that key.
Which key type
Ed25519 unless something stops you. It is ssh-keygen’s default since OpenSSH 9.5, OpenSSH has accepted it since 6.5 in January 2014, and there is nothing to choose. RSA of 3072 bits or more is for servers and network devices that predate it; ECDSA is there for policies that name NIST curves.
A key on a security key — ed25519-sk or ecdsa-sk — keeps the private half on the device: the file in ~/.ssh is useless without the token, and every use needs a touch. It needs OpenSSH 8.2 or later on both ends. ecdsa-sk works with more tokens; ed25519-sk needs one that supports Ed25519. On a Mac, the ssh-keygen and ssh that come with the system have no FIDO support, so the page builds the command for OpenSSH from Homebrew.
Passphrase and KDF rounds
A passphrase encrypts the private key file, so a copied file — from a backup, a synced folder, a lost laptop — is not a usable key. ssh-keygen turns the passphrase into the encryption key with bcrypt_pbkdf repeated -a times. The default is 24 since OpenSSH 9.4, although the manual page still says 16; ssh-keygen 10.2 writes 24.
More rounds make each guess slower for whoever has the file and each unlock slower for you. Measured on 24 September 2026 on an Apple M5 Pro with ssh-keygen 10.2: 24 rounds unlock in about 0.2 seconds, 100 in 0.75, 200 in 1.5. The old PEM format (-m PEM) has no rounds at all: its passphrase goes through a single round of MD5, so use it only for software that cannot read OpenSSH’s own format.
After the key exists
ssh-copy-id appends the public key to ~/.ssh/authorized_keys on the server, creating the file with the permissions sshd expects. Windows has no ssh-copy-id, so the PowerShell version pipes the key through ssh itself.
IdentitiesOnly yes in the config block makes ssh offer only this key to that host rather than every key it can find. Servers count each offered key as an attempt, and a few too many ends in “Too many authentication failures” before the right key is tried.
Questions people actually ask
Does this page see my passphrase?
No, and it cannot: there is no field for it. With a passphrase chosen, the command has no -N, so ssh-keygen asks for it in your terminal. The page itself sends nothing anywhere — no fetch, no XMLHttpRequest, no form submission, no analytics.
Ed25519 or RSA?
Ed25519, unless a server or device cannot take it. It is ssh-keygen’s default since OpenSSH 9.5, its public key is 68 characters, and there are no sizes to choose. If you need RSA, use 3072 bits or more.
What does -a do in ssh-keygen?
It sets how many rounds of bcrypt_pbkdf turn your passphrase into the key that encrypts the private key file. More rounds make guessing slower for anyone who steals the file. The default has been 24 since OpenSSH 9.4, and it only matters when the key has a passphrase.
What is a resident FIDO key?
-O resident stores the key handle on the security key itself, so on another computer ssh-keygen -K can download it again and you do not have to copy the file. Anyone holding the token and its PIN can do the same, so set a PIN first.
Why is there no -N in the PowerShell command?
Because PowerShell passes an empty argument differently before and after version 7.3, and no spelling of an empty -N works in both. Press Enter twice when ssh-keygen asks for a passphrase and the result is the same.
Can Conchshell use a key made this way?
Yes for Ed25519, ECDSA and RSA keys in OpenSSH’s own format — what ssh-keygen writes unless you add -m PEM — with or without a passphrase: it reads the private key file directly. An RSA key written with -m PEM works too, but version 2.16.0 cannot read an ECDSA key written with -m PEM; ssh-keygen -p -f on that file rewrites it in OpenSSH’s format. It cannot use security-key (-sk) keys, and it does not talk to ssh-agent.
Where this comes from
If ssh-keygen is not at hand — an older Windows, a borrowed machine — Conchshell can make the key itself: Create… next to the key field in its connection dialog makes an Ed25519, RSA (2048, 3072 or 4096 bits) or ECDSA key, with an optional passphrase. It writes both halves to the path you choose, shows the public line and its SHA256 fingerprint, and never displays the private half. It does not make security-key (-sk) keys.
When you import your ~/.ssh/config, it takes HostName, User, Port, IdentityFile and the first ProxyJump hop from each Host entry — so a block made here arrives with the key already attached.
Read next
- SSH key fingerprints — SHA256 and MD5, known_hosts and hashed hosts
- Check an SSH public key — algorithm, size and a grade from A to D
- Check your ~/.ssh/config — ciphers, MACs and host-key settings
- All the tools on this site