A Beginner’s Guide to Setting Up SSH Keys for GitHub

GitHub authentication has evolved over time, and passwords are no longer considered secure enough for daily Git operations. If you use GitHub regularly, you’ve probably been asked for a username, password while pushing code.
SSH (Secure Shell) is a protocol that allows you to securely connect and authenticate to remote servers and services. When used with GitHub, it lets GitHub recognize and trust your machine without repeatedly asking for credentials.
What is an SSH Key?
An SSH key acts like a digital identity for your machine. So instead of authenticating you every time, GitHub authenticates your machine. Your machine keeps a private key (which is secret) and GitHub stores a public key (which is safe to share).
In this blog, we’ll walk through how to set up an SSH key on a Windows laptop, step by step, in the simplest way possible. Let’s get started!
Step 1: Open Git Bash
Step 2: Check if an SSH Key Already Exists
Before creating a new key, check if your system already has one.
ls ~/.sshIf the folder doesn’t exist, it simply means no SSH key has been created yet. This is normal and expected behaviour. Proceed to Step # 3.
Note: If the .ssh folder already exists, it simply means SSH has been used on this machine before. And as a result you may see id_ed25519 (Private Key) and id_ed25519.pub (Public Key).
In this case, you have two options:
Reuse the existing key (skip to Step # 4)
Create a new key for a fresh setup (continue to Step # 3)
Step 3: Generate a new SSH key
Create a new SSH key using the following command:
ssh-keygen -t ed25519 -C "your_email@example.com"When prompted for the file location, press Enter to use the default.You may also set a passphrase for extra security, but this step is optional.
Once the key is generated, the .ssh folder will be created automatically.
Try looking for SSH folder again, Run:
ls ~/.sshResults will show something like:
id_ed25519
id_ed25519.pubTwo files are now created, id_ed25519 (Private Key) and id_ed25519.pub Public Key — goes to GitHub). Never share your private key (id_ed25519). It should stay only on your local machine.
Step 4: Start the SSH agent
The SSH agent allows Git to use your key.
eval "$(ssh-agent -s)"This command starts a helper program that keeps your keys ready for Git.
You’ll see:
Agent pid 1234Step 5: Add the SSH key to the agent
Run below command:
ssh-add ~/.ssh/id_ed25519This command loads your private key into memory. If you have set a passphrase enter it now.
Step 6: Copy the public SSH key
Run below command:
cat ~/.ssh/id_ed25519.pubThis displays your public key. Copy the entire line that starts with “ssh-ed25519”
Step 7: Add SSH key to GitHub
Go to github.com
Click your profile photo → Settings
Click SSH and GPG keys
Click New SSH key
Fill in the details:
Title: <My Windows Laptop>
Key type: Authentication Key
Key: Paste the copied key
6. Click Add SSH key
7. On the prompted screen, enter the GitHub login password
SSH Keys will be displayed successfully on the GitHub account page.
Step 8: Test the SSH connection
Go to Git Bash. Run below command:
ssh -T git@github.comIf checking for the first time, you may see:
Are you sure you want to continue connecting?Type “yes” for this question.
A success message will appear:
Hi <username>! You've successfully authenticated...Congratulations! SSH is working!
Once set up, SSH quietly works in the background — secure, fast, and hassle-free.
Hope you find this information helpful! Happy Learning :)


