RSA & SSH Key Generator · Tutorial
How to create an SSH key and add it to GitHub
8 min readbeginnerUpdated
GitHub, GitLab and most servers prefer SSH keys over passwords. This tutorial creates an Ed25519 key pair, saves the private key where Git expects it, adds the public key to your GitHub account, and checks that everything works.
What you need
- The RSA & SSH Key Generator
- A GitHub account (GitLab and Bitbucket work the same way)
- A terminal, to move the file and run the final test
Steps
Generate the key
Keep Ed25519 (recommended) selected, type a comment that identifies this computer, such as
amara@laptop, and press Generate key pair.Save the private key
Press Download next to the private key. Move the downloaded
id_ed25519file into the.sshfolder in your home directory, then make it private and add a passphrase.mkdir -p ~/.ssh && mv ~/Downloads/id_ed25519 ~/.ssh/ chmod 600 ~/.ssh/id_ed25519 ssh-keygen -p -f ~/.ssh/id_ed25519Add the public key to GitHub
Copy the public key (the line starting with
ssh-ed25519). On GitHub, open Settings → SSH and GPG keys → New SSH key, give it a title like "Laptop", paste the key and save.Test the connection
Run the command below. The first time, confirm GitHub's host fingerprint. You should see a greeting with your username.
ssh -T git@github.comUse SSH URLs
Clone with SSH addresses, such as
git@github.com:owner/repo.git, or switch an existing repository withgit remote set-url origin git@github.com:owner/repo.git.
Try it yourself
Opens the RSA & SSH Key Generator.
Common mistakes
- Pasting the private key into GitHub
- Only the one-line public key goes into GitHub. The private key stays on your computer. If you pasted it somewhere, delete the key and generate a new one.
- Wrong file permissions
- SSH refuses private keys that others can read, with a "permissions are too open" warning. Fix it with
chmod 600. - Leaving the key without a passphrase
- An unprotected key file gives full access to anyone who copies it. Add a passphrase and use
ssh-addso you only type it once per session.
Next steps
Go back to the RSA & SSH Key Generator, or keep going with one of these:
FAQ
Can I use the same key on several services?
Yes, but a separate key per computer is better. Then you can remove one device's access without affecting the others.