Learn how to add an SSH key to GitHub with our step-by-step guide—check for an existing key, generate a new one, add it to the agent, copy, and test your connection.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Check for existing SSH keys
Before creating a new SSH key, verify whether you already have one on your machine.
ls -al ~/.ssh
Look for files named id_rsa
, id_ed25519
, etc. If you already have a key you want to use, skip to Step 4.
Step 2: Generate a new SSH key
Create a new SSH key pair using the Ed25519 algorithm (recommended) or RSA if needed.
your\[email protected]
with your GitHub email address.ssh-keygen -t ed25519 -C "your\[email protected]"
When prompted:
Enter
.Enter
twice for no passphrase.
Step 3: Add your SSH private key to the SSH agent
The SSH agent manages your keys and passphrases during a session.
eval "$(ssh-agent -s)"
id\_ed25519
if you used a different name):ssh-add ~/.ssh/id\_ed25519
Step 4: Copy the SSH public key to your clipboard
You need to copy the contents of your public key file (\*.pub
) to GitHub.
pbcopy < ~/.ssh/id\_ed25519.pub
xclip -sel clip < ~/.ssh/id\_ed25519.pub
clip < ~/.ssh/id\_ed25519.pub
Step 5: Add the SSH key to your GitHub account
Now paste the copied key into your GitHub SSH keys settings.
Step 6: Test your SSH connection
Verify that GitHub recognizes your key.
ssh -T [email protected]
You should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Step 7: Configure Git to use SSH (optional)
If you cloned repos over HTTPS, update the remote URL to SSH:
cd path/to/your-repo
git remote set-url origin [email protected]:username/your-repo.git
git remote -v
You’re now set up to securely communicate with GitHub over SSH!
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.