📘Git and Github
Estimated reading: 3 minutes 22 views

🔐 Git SSH Key Setup: Passwordless GitHub Access in Remote Repository


🧲 Introduction

Tired of typing your GitHub password every time you push or pull code? 🤯 There’s a better way — SSH authentication.

Setting up an SSH key allows you to connect securely to platforms like GitHub without entering your username and password each time. This guide will show you exactly how to generate, register, and use your SSH key in Git.


🚀 Step-by-Step: SSH Key Setup for Git


1️⃣ Open Your Terminal

Fire up your terminal (Mac/Linux) or Git Bash (Windows).


2️⃣ Navigate to Your Home Directory

cd ~

This ensures your SSH keys are stored in the right location.


3️⃣ Generate an SSH Key

Run the following:

ssh-keygen

Then:

  • Press Enter to accept the default file location
  • Press Enter again to skip setting a passphrase (optional)
  • Press Enter one last time to confirm

✅ You’ve now created an SSH key pair!


4️⃣ Go to the .ssh Folder

cd .ssh

5️⃣ List Your SSH Files

ls

You should see:

  • id_rsa – your private key (💀 do NOT share this)
  • id_rsa.pub – your public key (📤 safe to share)

6️⃣ Copy Your Public Key

cat id_rsa.pub

Copy the entire output. You’ll paste this into GitHub next.


🧷 Add SSH Key to GitHub

  1. Log in to your GitHub account
  2. Go to Settings > SSH and GPG Keys
  3. Click New SSH Key
  4. Add a title (e.g., “Work Laptop Key”)
  5. Paste your copied public key
  6. Click Add SSH Key

🎉 You’ve now linked your local SSH key to GitHub!


🛠 Clone a Git Repository Using SSH

Rather than using the HTTPS URL, copy the SSH URL:

git@github.com:username/repo.git

Then clone:

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

🧠 First Time? You’ll See:

Are you sure you want to continue connecting (yes/no)?

Type:

yes

Boom! You’re in with no password needed.


🛠 Cloning with SSH vs HTTPS (Simple Explanation)

Link TypeLooks LikeRequires Password?
HTTPShttps://github.com/Yes (every time)
SSHgit@github.com:…No (uses SSH key)

🔐 SSH = secure + seamless. One-time setup = passwordless Git.


🧠 Summary – Recap & Next Steps

Setting up SSH for Git not only saves you time — it strengthens your security and simplifies collaboration.

🔍 Key Takeaways:

  • SSH keys allow passwordless Git operations.
  • Use ssh-keygen to create a key, and add the .pub file to GitHub.
  • Always use the SSH clone URL, not HTTPS.
  • Confirm setup using: ssh -T git@github.com

⚙️ Real-World Relevance:

  • Used in real teams and CI/CD pipelines.
  • Great for automation and scripting (no password prompts).
  • Works with GitHub, GitLab, Bitbucket, and more.

❓ FAQ – Frequently Asked Questions


🔸 Q1: Do I need to do this every time I use Git?

✅ Nope! Once your key is added to GitHub, Git will use it automatically.


🔸 Q2: What if I already have an .ssh folder and keys?

✅ You can:

  • Reuse existing keys (just add the .pub to GitHub)
  • Or generate a new one and name it differently (e.g., id_git_rsa)

🔸 Q3: What’s the difference between id_rsa and id_rsa.pub?

  • id_rsa: Your private key (never share it)
  • id_rsa.pub: Your public key (safe to upload)

🔸 Q4: How do I check if my SSH key is working?

Run:

ssh -T git@github.com

If successful, you’ll see:

Hi username! You've successfully authenticated.

🔸 Q5: I get a “Permission denied” error. What should I do?

✅ Troubleshooting checklist:

  • Ensure you’ve added the correct .pub key to GitHub
  • Use the SSH clone URL (not HTTPS)
  • Start your SSH agent and add the key:
ssh-add ~/.ssh/id_rsa

Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

Git SSH Key Setup for password less entry in Remote Repository

Or Copy Link

CONTENTS
Scroll to Top