Check for Existing SSH Keys
ls -al ~/.ssh
Generate a New SSH Key
If no keys are found, generate one:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Start the SSH Agent (optional)
Why?: The agent manages your keys and prevents you from entering your passphrase every time.
eval "$(ssh-agent -s)"
Add SSH Key to Agent
ssh-add ~/.ssh/id_rsa
Copy the SSH Public Key
cat ~/.ssh/id_rsa.pub
Add the Key to GitHub
- Go to GitHub > Settings > SSH and GPG keys > New SSH key.
- Paste the copied key.
Test SSH Connection
ssh -T git@github.com
Update Git Remote URL
git remote set-url origin git@github.com:uname/repo.git
Done! You're all set to use SSH with GitHub!
Top comments (0)