Open Terminal and run:
ssh-keygen -t ed25519 -C "your-email@example.com"Open PowerShell or Git Bash and run:
ssh-keygen -t ed25519 -C "your-email@example.com"Important: Use the same email address associated with your GitHub account.
When prompted:
You should see output like:
Your identification has been saved in /Users/yourname/.ssh/id_ed25519 # Mac
Your identification has been saved in C:\Users\yourname\.ssh\id_ed25519 # Windows
Your public key has been saved in [same path].pub# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your SSH key to the agent
ssh-add ~/.ssh/id_ed25519# Start the SSH agent (run as Administrator if needed)
Start-Service ssh-agent
# Add your SSH key to the agent
ssh-add ~/.ssh/id_ed25519# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your SSH key to the agent
ssh-add ~/.ssh/id_ed25519If you get a "No such file" error, your key might be named differently. Check with:
ls ~/.ssh/dir ~/.ssh/ or ls ~/.ssh/ (in Git Bash)pbcopy < ~/.ssh/id_ed25519.pubGet-Content ~/.ssh/id_ed25519.pub | Set-Clipboardclip < ~/.ssh/id_ed25519.pubIf clipboard commands don't work:
cat ~/.ssh/id_ed25519.pubThen manually select and copy the output.
Don't paste it anywhere yet!
ssh -T git@github.comYou should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.If you get a "Permission denied" error, double-check the previous steps.
For any existing repositories, change from HTTPS to SSH:
# Check current URL
git remote -v
# If it shows https://github.com/..., change it:
git remote set-url origin git@github.com:username/repository-name.git
# Verify the change
git remote -vFrom now on, always use the SSH URL when cloning:
# ✅ Correct (SSH)
git clone git@github.com:username/repository-name.git
# ❌ Avoid (HTTPS)
git clone https://github.com/username/repository-name.gitHow to get SSH URL: On any GitHub repository page, click the green "Code" button and select "SSH" tab.
Mac/Linux:
# Make sure your key is added to the SSH agent
ssh-add -l
# If empty, add your key again
ssh-add ~/.ssh/id_ed25519Windows:
# Check if key is loaded
ssh-add -l
# If empty or error, restart SSH agent and add key
# In PowerShell (as Administrator):
Start-Service ssh-agent
ssh-add ~/.ssh/id_ed25519
# Or in Git Bash:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Mac/Linux:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Windows (PowerShell):
Start-Service ssh-agent
ssh-add ~/.ssh/id_ed25519Windows (Git Bash):
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519git@github.com:user/repo.gitssh -T git@github.comMac:
git config --global --unset credential.helper
# Also delete "github.com" entries from Keychain Access appWindows:
git config --global --unset credential.helper
# Also check Windows Credential Manager and remove GitHub entries| Task | Mac/Linux | Windows (PowerShell) | Windows (Git Bash) |
|---|---|---|---|
| Generate SSH key | ssh-keygen -t ed25519 -C "email" | ssh-keygen -t ed25519 -C "email" | ssh-keygen -t ed25519 -C "email" |
| Start SSH agent | eval "$(ssh-agent -s)" | Start-Service ssh-agent | eval "$(ssh-agent -s)" |
| Add key to agent | ssh-add ~/.ssh/id_ed25519 | ssh-add ~/.ssh/id_ed25519 | ssh-add ~/.ssh/id_ed25519 |
| Copy public key | pbcopy < ~/.ssh/id_ed25519.pub | Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard | clip < ~/.ssh/id_ed25519.pub |
| Test connection | ssh -T git@github.com | ssh -T git@github.com | ssh -T git@github.com |
| Change remote to SSH | git remote set-url origin git@github.com:user/repo.git | git remote set-url origin git@github.com:user/repo.git | git remote set-url origin git@github.com:user/repo.git |