Here's a simplified guide to generate an SSH key on Ubuntu and link it with Git and a GitHub profile:
-
Generate SSH Key:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
When prompted, press
Enter
to accept the default file path and filename. -
Start the SSH Agent and Add Your Key:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa
-
Display the SSH Key:
cat ~/.ssh/id_rsa.pub
This will display your public SSH key in the terminal. Manually select the content and copy it using your mouse or terminal's copy function.
-
Link SSH Key to GitHub:
- Go to GitHub and log into your account.
- Click on your profile picture in the top right corner, and then click on Settings.
- In the left sidebar, click on SSH and GPG keys.
- Click the New SSH key button.
- Paste your copied SSH key into the "Key" field.
- Give it a meaningful title and then click Add SSH key.
-
Test the Connection:
ssh -T [email protected]
If everything went well, you should see a message saying that you've successfully authenticated.
-
Configure Git (if not done before):
git config --global user.name "Your Name" git config --global user.email "[email protected]"
That's it! You've generated an SSH key on Ubuntu, linked it to Git, and associated it with your GitHub profile.