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

ssh-keygen with no arguments makes an Ed25519 key. Pick rsa only for a server that cannot take ed25519.

A label stored in the .pub file. It is not checked and not secret.

The private key path. The public key is the same path plus .pub. Leave blank for OpenSSH's usual name for the type, or use a name like ~/.ssh/github_work so one key does not overwrite another.

With 'ask', ssh-keygen prompts you, so the passphrase never appears in your shell history.

Each round makes a stolen key file slower to brute-force and your own unlock a little slower. ssh-keygen's default is 32; the line is left out when you set 32.

What you type after ssh. A different alias (for example github-work) lets two accounts on one host use two keys.

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?

Key types ssh-keygen -t accepts, and what each needs (OpenBSD ssh-keygen man page, GitLab SSH docs, read 2026-11-11)
-t valueSize flagUse it whenWatch out for
ed25519none (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 onlyA system that specifically asks for ECDSA.Any other size makes ssh-keygen fail.
ed25519-sknoneA FIDO2 security key; the private part stays on the token.Needs OpenSSH 8.2+ on both client and server (GitLab).
ecdsa-sknoneA FIDO token that does not support Ed25519.Same OpenSSH 8.2+ requirement.

How to generate and install an SSH key

  1. 1
    Choose 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.
  2. 2
    Choose 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.
  3. 3
    Copy 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.
  4. 4
    Add 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?
No. It builds the command text only, so the private key is created by ssh-keygen on your own computer. Nothing you type here, including the comment and file path, is sent to a server.
Is it safe to use an empty passphrase with -N ""?
It works, but anyone who gets a copy of the private key file can sign in as you, because nothing protects it. Use it only for an unattended automation key on a locked-down machine. For a laptop key, let ssh-keygen prompt you.
What are the -a rounds for?
-a sets how many rounds the passphrase-based key derivation runs. More rounds make guessing the passphrase of a stolen key file slower, at the cost of a slightly slower unlock for you. The OpenSSH default is 32.
Why do I need IdentitiesOnly yes in ~/.ssh/config?
Without it, ssh may offer every key in your agent before the one you named, and a server that limits attempts can lock you out before the right key is tried. With IdentitiesOnly yes, ssh uses only the IdentityFile for that host.
How do I use two GitHub accounts with two keys?
Make two keys with different file names, give each a Host alias in ~/.ssh/config that points HostName at github.com, and clone with the alias, like git@github-work:org/repo.git. Set a different alias in this tool for each key.
How do I check which key is which?
Run ssh-keygen -lf on the .pub file to print its SHA256 fingerprint, and compare it with the fingerprint your provider lists next to the key. ssh-add -l shows the fingerprints of the keys currently in your agent.
What does --apple-use-keychain do?
On macOS it stores your passphrase in the keychain when you add the key to ssh-agent, so you are not asked again after a restart. Omit it if the key has no passphrase, and note that it is an Apple build option, not in the OpenBSD man pages.

Sources

Related tools

See all 135 free tools

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