This guide walks you through the process of setting up an SSH key for authenticating with GitHub on Ubuntu.
Before generating a new SSH key, check if you already have existing keys. Open a terminal and run:
ls -al ~/.ssh
Look for existing keys, typically id_rsa
and id_rsa.pub
.
If you don't have an existing SSH key, generate a new one:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Follow the on-screen prompts, and you can leave the passphrase empty for simplicity.
Start the SSH agent:
eval "$(ssh-agent -s)"
Add your SSH key to the agent:
ssh-add ~/.ssh/id_rsa
Copy the SSH key to your clipboard:
xclip -sel clip < ~/.ssh/id_rsa.pub
if xclip is not installed then
Display the SSH key:
cat ~/.ssh/id_rsa.pub
Copy the displayed key.
Go to your GitHub account > Settings > SSH and GPG keys > New SSH key, and paste the copied key.
Test the SSH connection to GitHub:
ssh -T git@github.com
If successful, you'll see a message indicating authentication.
You have successfully set up an SSH key for GitHub on Ubuntu. This allows secure and convenient authentication when interacting with GitHub repositories.
This guide covers the key steps to set up and configure an SSH key for GitHub on Ubuntu. Users can follow the instructions to ensure a secure and seamless authentication process when interacting with GitHub repositories
Go back to GitHub Guide.
Visit other Developer Guides.