Git SSH Setup: Secure Authentication for Remote Repositories
Why SSH Over HTTPS
HTTPS requires you to enter your username and password (or personal access token) for every push. SSH uses cryptographic key pairs — once configured, you never type credentials again.
Generating an SSH Key
ssh-keygen -t ed25519 -C "your.email@example.com" # Follow the prompts (press Enter for defaults)
This creates two files:
~/.ssh/id_ed25519— your private key (never share this)~/.ssh/id_ed25519.pub— your public key (goes on the server)
Adding Your Key to the SSH Agent
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
Adding the Key to GitHub
cat ~/.ssh/id_ed25519.pub # Copy the entire output
Go to GitHub → Settings → SSH and GPG keys → New SSH key. Paste and save.
Testing the Connection
ssh -T git@github.com # Hi username! You've successfully authenticated.
Cloning with SSH
git clone git@github.com:username/repository.git
Use the SSH URL format (git@github.com:user/repo.git) instead of the HTTPS URL (https://github.com/user/repo.git).
Multiple SSH Keys
If you use multiple Git services (GitHub + GitLab + Bitbucket), use a config file:
# ~/.ssh/config Host github.com HostName github.com IdentityFile ~/.ssh/id_ed25519_github Host gitlab.com HostName gitlab.com IdentityFile ~/.ssh/id_ed25519_gitlab
Troubleshooting
# Verbose output shows every step ssh -vT git@github.com # Permission denied? Check your key is added to the agent ssh-add -l # Wrong key? Specify which one to use ssh -i ~/.ssh/id_ed25519 -T git@github.com
SSH authentication is a one-time setup that saves thousands of password prompts over the life of your project.
Master upstream tracking, SSH auth, and team workflows
Upstream sync strategies, merge vs rebase on pull, and semantic release tagging in the 97-page course — ₹499.
Related Git Command References
All 28 commands →Syntax breakdowns and practical terminal examples for commands used in this topic
More on Remotes & Team Collaboration
All articles →- Guide
Git Submodules: Managing Dependencies Across Repositories
Include one repository inside another with git submodules. A practical guide to adding, updating, and working with nested repos.
Read guide - Tutorial
Git Tagging: Versioning Your Project Milestones
Mark important commits with tags for releases, versions, and milestones. Learn lightweight vs annotated tags and how to share them.
Read guide