how to setup ssh key in github ?

0

Hi in this blog I will be teaching how to setup ssh key in github


 


1. Check for Existing SSH Keys

Open terminal and run:

ls -al ~/.ssh

If you see files like:

id_rsa.pub
id_ed25519.pub

You already have a key (you can reuse it or create a new one).


2. Generate a New SSH Key

Recommended (modern and secure):

ssh-keygen -t ed25519 -C "your_email@example.com"

If your system doesn’t support it:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Press:

  • Enter → save in default location

  • Enter → skip passphrase (or add one for security)


3. Start SSH Agent

eval "$(ssh-agent -s)"

4. Add SSH Key to Agent

ssh-add ~/.ssh/id_ed25519

5. Copy SSH Public Key

cat ~/.ssh/id_ed25519.pub

Copy the output (starts with ssh-ed25519).


6. Add Key to GitHub

  1. Go to GitHub

  2. Click profile → Settings

  3. Go to SSH and GPG keys

  4. Click New SSH Key

  5. Paste your key

  6. Click Add SSH Key


7. Test SSH Connection

ssh -T git@github.com

Expected output:

Hi username! You've successfully authenticated...

8. Use SSH Instead of HTTPS

When cloning a repo, use:

git clone git@github.com:username/repo.git

Example:

git clone git@github.com:akash/repo.git

Common Issues & Fixes

❌ Permission denied (publickey)

Fix:

ssh-add ~/.ssh/id_ed25519

❌ Wrong remote URL

Check:

git remote -v

Update:

git remote set-url origin git@github.com:username/repo.git

❌ SSH not running

Restart:

eval "$(ssh-agent -s)"


Thanks for reading this blog.

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !