📌 Prerequisites
-
A GitHub account
-
Git installed (
sudo apt install git
) -
OpenSSH client installed (
sudo apt install openssh-client
)
🔑 Step 1: Check for Existing SSH Keys
ls -al ~/.ssh
Look for files like id_rsa.pub
or id_ed25519.pub
. If they exist, you might already have an SSH key.
🛠️ Step 2: Generate a New SSH Key
ssh-keygen -t ed25519 -C "[email protected]"
If you’re using an older system that doesn’t support Ed25519:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
When prompted to “Enter a file in which to save the key,” press Enter to accept the default.
-
Set a secure passphrase (optional, but recommended).
📂 Step 3: Add Your SSH Key to the SSH Agent
Start the SSH agent:
eval "$(ssh-agent -s)"
Add your SSH key:
ssh-add ~/.ssh/id_ed25519
Replace
id_ed25519
with your actual key file if you used a different name.
📋 Step 4: Copy SSH Key to Clipboard
If you have xclip
installed:
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
Or use:
cat ~/.ssh/id_ed25519.pub
Then manually copy the output.
🌐 Step 5: Add SSH Key to GitHub
-
Go to GitHub SSH settings
-
Click New SSH Key
-
Paste your public key
-
Give it a descriptive title
-
Click Add SSH key
✅ Step 6: Test Your SSH Connection
ssh -T [email protected]
You should see a message like:
Hi your_username! You've successfully authenticated...