SSH Keygen Command Generator
Pick the key type, comment, file and passphrase and get the exact ssh-keygen command, with the agent, keychain, config and public-key steps for GitHub, GitLab, Bitbucket or your server. It only writes command text, so no key or passphrase is created or sent anywhere.
Updated
Commands to run in your terminal
# 1. Generate the key pair (private key stays on this computer) mkdir -p ~/.ssh && chmod 700 ~/.ssh ssh-keygen -t ed25519 -a 100 -C you@example.com -f ~/.ssh/id_ed25519 # 2. Load it into ssh-agent so you type the passphrase once eval "$(ssh-agent -s)" ssh-add --apple-use-keychain ~/.ssh/id_ed25519 # 3. Tell ssh which key goes with this host (~/.ssh/config) cat >> ~/.ssh/config <<'EOF' Host github.com IgnoreUnknown UseKeychain User git IdentityFile ~/.ssh/id_ed25519 IdentitiesOnly yes AddKeysToAgent yes UseKeychain yes EOF chmod 600 ~/.ssh/config # 4. Add the public key to GitHub pbcopy < ~/.ssh/id_ed25519.pub # copies the public key; paste it on the site # GitHub: profile picture > Settings > Access > SSH and GPG keys > New SSH key, key type Authentication Key, paste the .pub line # Steps: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account # 5. Check it ssh -T git@github.com ssh-keygen -lf ~/.ssh/id_ed25519.pub # prints the SHA256 fingerprint; compare it with what the site shows
- Private key
- ~/.ssh/id_ed25519stays on your computer
- Public key
- ~/.ssh/id_ed25519.pubthe file you give to GitHub, GitLab or a server
- Algorithm
- ed25519
- Key derivation rounds
- 100
- Nothing you type here is sent anywhere. This page builds command text only; the key is made by ssh-keygen on your machine.
- IgnoreUnknown UseKeychain is there because GitHub says non-Apple builds of OpenSSH fail with "Bad configuration option: usekeychain" without it.
- The first connection asks you to confirm the host's fingerprint. Compare it with the one the provider publishes before typing yes.
- Share only the .pub file. Never paste the private key (the file without .pub) into a website, chat or ticket, including this page.
How does this build the ssh-keygen command?
This page never makes a key. It writes the text of the commands you then run in your own terminal, so the private key is created on your computer by OpenSSH and no key, passphrase or file path is sent anywhere. The page also has no field for a private key, and you should never paste one into any website.
The ssh-keygen line follows the OpenBSD man page: -t picks the type (ecdsa, ecdsa-sk, ed25519, ed25519-sk or rsa, with Ed25519 the default when you give no arguments), -b sets the size for rsa (default 3072, minimum 1024) and ecdsa (only 256, 384 or 521), -a sets the key-derivation rounds that slow down brute-forcing a stolen key file (default 32), -C sets the comment, -f the file and -N the passphrase. For hardware keys, -O resident stores the key handle on the token and -O verify-required asks for the PIN or a fingerprint on every signature.
The rest is the routine that surrounds the key. ssh-add puts it in the agent so you unlock it once; on macOS --apple-use-keychain also stores the passphrase in the keychain. A Host block in ~/.ssh/config tells ssh which file to use for which host (IdentityFile, with IdentitiesOnly yes so the agent does not offer every other key first). ssh-copy-id appends the public key to ~/.ssh/authorized_keys on your own server, and for GitHub, GitLab and Bitbucket you paste the .pub line into their settings. ssh-keygen -lf prints the fingerprint so you can compare it.
ssh-keygen -t <type> [-b <bits>] [-a <rounds>] [-O resident] -C <comment> -f <file> [-N ""] private key = <file> public key = <file>.pub fingerprint = ssh-keygen -lf <file>.pub
Which SSH key type should I choose?
| -t value | Size flag | Use it when | Watch out for |
|---|---|---|---|
| ed25519 | none (fixed size) | The default. Works on GitHub, GitLab, Bitbucket and current OpenSSH servers. | Very old servers may not know it. |
| rsa | -b 3072 or more (default 3072, minimum 1024) | A legacy system that refuses ed25519. GitLab recommends at least 4096. | Bigger keys are slower; anything below 3072 is refused here. |
| ecdsa | -b 256, 384 or 521 only | A system that specifically asks for ECDSA. | Any other size makes ssh-keygen fail. |
| ed25519-sk | none | A FIDO2 security key; the private part stays on the token. | Needs OpenSSH 8.2+ on both client and server (GitLab). |
| ecdsa-sk | none | A FIDO token that does not support Ed25519. | Same OpenSSH 8.2+ requirement. |
How to generate and install an SSH key
- 1Choose the keyLeave ed25519 unless a server needs rsa. Set a comment such as your email or laptop name, and a file name that is not already used, so a new key never overwrites an old one.
- 2Choose where it will be usedPick GitHub, GitLab, Bitbucket or your own server, and your computer (macOS or Linux). The commands change to match, including the keychain flag and the config entry.
- 3Copy the commandsCopy the block into your terminal and run it one section at a time. When ssh-keygen asks for a passphrase, type one; it does not echo and does not enter your shell history.
- 4Add the public keyPaste the .pub line into the provider's settings page (linked in the output), or let ssh-copy-id install it on your server. Then run the test line and compare the fingerprint.
Frequently asked questions
Does this page generate my SSH key?
Is it safe to use an empty passphrase with -N ""?
What are the -a rounds for?
Why do I need IdentitiesOnly yes in ~/.ssh/config?
How do I use two GitHub accounts with two keys?
How do I check which key is which?
What does --apple-use-keychain do?
Sources
- OpenBSD ssh-keygen(1): key types, -b sizes, -a rounds, -N, -C, -f, -l, -O resident / verify-required, -K (checked 11 Nov 2026)
- OpenBSD ssh-add(1): -l, -L, -t, -D (checked 11 Nov 2026)
- OpenBSD ssh_config(5): Host, HostName, User, Port, IdentityFile, IdentitiesOnly, AddKeysToAgent (checked 11 Nov 2026)
- ssh-copy-id(1) (OpenSSH portable): -i, -p, -n and what it does (checked 11 Nov 2026)
- GitHub Docs: Generating a new SSH key and adding it to the ssh-agent (ed25519 command, --apple-use-keychain, UseKeychain config) (checked 11 Nov 2026)
- GitHub Docs: Adding a new SSH key to your GitHub account (menu path, copy commands) (checked 11 Nov 2026)
- GitLab Docs: Use SSH keys to communicate with GitLab (ED25519 preferred, RSA 4096, _SK needs OpenSSH 8.2) (checked 11 Nov 2026)
- Atlassian: Set up personal SSH keys on Linux (Bitbucket Cloud) (checked 11 Nov 2026)
Need a custom dev tool for your team?
We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter