Loading lessons...
Add an SSH Key
Add an SSH Key
To use SSH with GitHub, you create a key pair and upload the public key.
Step 1: Generate a key pair
Open your terminal and run:
ssh-keygen -t ed25519 -C "you@example.com"
Press Enter to accept the default file location. You can add a passphrase (recommended) or leave it empty.
The command creates two files:
id_ed25519(your private key, keep it secret)id_ed25519.pub(your public key, safe to share)
Step 2: Show your public key
cat ~/.ssh/id_ed25519.pub
Copy the whole output. It looks like:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... you@example.com
Step 3: Add it to GitHub
- Go to GitHub > Settings > SSH and GPG keys.
- Click New SSH key.
- Paste your public key and save.
Step 4: Test the connection
ssh -T git@github.com
If it works, GitHub greets you with a message like "Hi username! You've successfully authenticated."
TL;DR
- Generate keys with
ssh-keygen -t ed25519 -C "email". - Your public key is
id_ed25519.pub. - Paste it into GitHub Settings > SSH and GPG keys.
- Test with
ssh -T git@github.com.