If you’re working with Git and want to authenticate securely with services like GitHub or GitLab, SSH keys are a great option. In this guide, we will walk through how to generate and configure SSH keys on a Windows machine using Git Bash.
1. From the Windows machine
Check for Existing SSH Keys
ls -al ~/.ssh
If keys like id_rsa
or id_rsa.pub
exist, you already have SSH keys. If not, generate new ones.
Generate a New SSH Key
ssh-keygen -t rsa -b 4096 -C "YourGITemailAccount@domain.com"
- Location: Press Enter to accept the default (
~/.ssh/id_rsa
). - Passphrase: Optional but recommended for security.
eval "$(ssh-agent -s)"
This ensures the SSH agent is running.
ssh-add ~/.ssh/id_rsa
Copy the output (your public key) for the next step.
2. From the GitHub portal
Add the Key to Git Service
- Go to the GIT Icon fro the top right of portal → Settings → SSH Keys → SSH and GPG Keys
- Add SSH Key and paste your public key.
7. Test the Connection
ssh -T git@github.com
If successful, you’ll see like this:
I’ve spent time working in a software company and frequently received support requests from developers struggling to connect to Git after updating their passwords. Using SSH keys can eliminate these issues by providing a secure, password-less way to authenticate with Git services. Below is a step-by-step guide on how to configure Git SSH on a Windows machine using Git Bash
1. From the Windows machine
Check for Existing SSH Keys
ls -al ~/.ssh
If keys like id_rsa
or id_rsa.pub
exist, you already have SSH keys. If not, generate new ones.
Generate a New SSH Key
ssh-keygen -t rsa -b 4096 -C "YourGITemailAccount@domain.com"
- Location: Press Enter to accept the default (
~/.ssh/id_rsa
). - Passphrase: Optional but recommended for security.
eval "$(ssh-agent -s)"
This ensures the SSH agent is running.
ssh-add ~/.ssh/id_rsa
Copy the output (your public key) for the next step.
2. From the GitHub portal
Add the Key to Git Service
- Go to the GIT Icon fro the top right of portal → Settings → SSH Keys → SSH and GPG Keys
- Add SSH Key and paste your public key.
7. Test the Connection
ssh -T git@github.com
If successful, you’ll see like this: