How to Set Up GitHub SSH Authentication - Complete Setup Guide for Windows, Linux, and macOS

If you're still entering credentials every time you push or pull code from GitHub, it's time to switch to SSH authentication.
SSH (Secure Shell) allows GitHub to verify your identity using cryptographic keys instead of passwords or personal access tokens. Once configured, Git operations become faster, more secure, and significantly more convenient.
In this guide, you'll learn how to set up GitHub SSH authentication using ED25519 keys on Windows, Linux, and macOS.
Why Use SSH with GitHub?
SSH authentication offers several benefits:
Secure cryptographic authentication
No need to repeatedly enter credentials
Faster Git operations
Better support for automation and CI/CD workflows
Recommended by GitHub for repository access
Once configured, you can clone, pull, and push repositories without being prompted for GitHub credentials.
Prerequisites
Before getting started, make sure Git is installed on your system.
Tip: If Git is not installed, use the appropriate installation method for your operating system.
Windows
Download and install Git from:
https://git-scm.com/downloads
Ubuntu / Debian
sudo apt update
sudo apt install git
Fedora
sudo dnf install git
Arch Linux
sudo pacman -S git
macOS (Homebrew)
brew install git
Verify the installation:
git --version
You should see the installed Git version displayed in your terminal.
Step 1: Generate an SSH Key
Open your terminal and run:
ssh-keygen -t ed25519 -C "your-email@example.com"
Replace the email address with the one associated with your GitHub account.
Example:
ssh-keygen -t ed25519 -C "john@example.com"
You'll be prompted to choose a location for the key:
Enter file in which to save the key
Simply press Enter to use the default location.
You will then be asked to create a passphrase:
Enter passphrase (empty for no passphrase):
A passphrase is optional but recommended because it adds an extra layer of protection if your private key is ever exposed.
After completion, you should see output similar to:
Your identification has been saved in ~/.ssh/id_ed25519
Your public key has been saved in ~/.ssh/id_ed25519.pub
Step 2: Verify the SSH Key Files
Verify that the key pair was created successfully.
Linux / macOS
ls -la ~/.ssh
Windows
dir %USERPROFILE%\.ssh
You should see files similar to:
id_ed25519
id_ed25519.pub
The private key:
id_ed25519
The public key:
id_ed25519.pub
Never share your private key with anyone. Only the public key should be uploaded to GitHub.
Step 3: Display Your Public Key
Copy your public key using one of the following commands.
Linux / macOS
cat ~/.ssh/id_ed25519.pub
Windows
type %USERPROFILE%\.ssh\id_ed25519.pub
The output will look similar to:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your-email@example.com
Copy the entire line.
Step 4: Add the SSH Key to GitHub
Log in to your GitHub account and navigate to:
https://github.com/settings/keys
Click New SSH Key.
Fill out the form:
Title
My Laptop
Key Type
Authentication Key
Paste the public key into the key field and click Add SSH Key.
GitHub may ask you to confirm your password or complete two-factor authentication.
Once saved, your device is authorized to authenticate with GitHub using SSH.
Step 5: Test the SSH Connection
Now it's time to verify that everything is working correctly.
Run:
ssh -T git@github.com
The first time you connect, you'll likely see:
The authenticity of host 'github.com' can't be established.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Type:
yes
and press Enter.
If the setup is successful, GitHub will respond with:
Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
This confirms that your SSH key is correctly configured and recognized by GitHub.
Step 6: Configure Git Identity
Before working with repositories, configure your Git username and email.
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
Verify the configuration:
git config --global --list
You should see your configured username and email address in the output.
Step 7: Clone a Repository Using SSH
Instead of cloning repositories using HTTPS:
https://github.com/username/repository.git
Use the SSH URL:
git@github.com:username/repository.git
Example:
git clone git@github.com:username/repository.git
The repository will now use SSH authentication automatically.
Step 8: Convert Existing Repositories from HTTPS to SSH
If you already have repositories cloned using HTTPS, you can switch them to SSH without recloning.
Check the current remote:
git remote -v
Example HTTPS remote:
https://github.com/username/repository.git
Change it to SSH:
git remote set-url origin git@github.com:username/repository.git
Verify the update:
git remote -v
You should now see:
git@github.com:username/repository.git
Step 9: Test Git Operations
Try pulling changes:
git pull
Or pushing changes:
git push
If everything is configured correctly, Git will authenticate automatically without requesting your GitHub credentials.
Common Issues and Fixes
Permission Denied (publickey)
If you receive:
Permission denied (publickey).
Check the following:
The public key was added to the correct GitHub account
The key was copied completely
The private key exists in your
.sshdirectoryYou're using the correct GitHub account
Verify authentication again:
ssh -T git@github.com
Repository Not Found
Ensure:
The repository exists
You have access permissions
The remote URL is correct
Check your remote URL:
git remote -v
Wrong GitHub Account
If you use multiple GitHub accounts, create separate SSH keys and configure SSH host aliases using the SSH config file.
This allows each repository to authenticate using the appropriate account.
Verify Which Remote Is Being Used
Run:
git remote -v
Expected output:
origin git@github.com:username/repository.git (fetch)
origin git@github.com:username/repository.git (push)
If you still see HTTPS URLs, update them using the commands shown earlier.
Understanding ED25519
You may have noticed the command uses:
ssh-keygen -t ed25519
ED25519 is a modern public-key signature algorithm designed to provide strong security with smaller key sizes and better performance than older alternatives like RSA.
GitHub recommends ED25519 keys whenever possible.
Unless you have a specific compatibility requirement, ED25519 is the preferred choice.
Final Thoughts
SSH authentication is one of the first configurations every developer should set up after installing Git.
The process takes only a few minutes, but it provides long-term benefits:
Improved security
Faster authentication
Better automation support
Cleaner Git workflows
Once configured, you'll be able to interact with GitHub repositories securely and efficiently without constantly entering credentials.
Whether you're contributing to open source projects, managing personal repositories, or working in professional development environments, SSH authentication is a setup worth implementing from day one.





![HTB Three Walkthrough [Tier 1]: Learning AWS S3 Enumeration and Bucket Exploitation](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F6a13c822551486ce6c514b17%2Fd9bd6589-e016-43b3-9d0d-2bb6b13c6f91.png&w=3840&q=75)