# 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:

```text
https://git-scm.com/downloads
```

### Ubuntu / Debian

```bash
sudo apt update
sudo apt install git
```

### Fedora

```bash
sudo dnf install git
```

### Arch Linux

```bash
sudo pacman -S git
```

### macOS (Homebrew)

```bash
brew install git
```

Verify the installation:

```bash
git --version
```

You should see the installed Git version displayed in your terminal.

* * *

## Step 1: Generate an SSH Key

Open your terminal and run:

```bash
ssh-keygen -t ed25519 -C "your-email@example.com"
```

Replace the email address with the one associated with your GitHub account.

Example:

```bash
ssh-keygen -t ed25519 -C "john@example.com"
```

You'll be prompted to choose a location for the key:

```text
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:

```text
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:

```text
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

```bash
ls -la ~/.ssh
```

### Windows

```cmd
dir %USERPROFILE%\.ssh
```

You should see files similar to:

```text
id_ed25519
id_ed25519.pub
```

The private key:

```text
id_ed25519
```

The public key:

```text
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

```bash
cat ~/.ssh/id_ed25519.pub
```

### Windows

```cmd
type %USERPROFILE%\.ssh\id_ed25519.pub
```

The output will look similar to:

```text
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:

```text
https://github.com/settings/keys
```

Click **New SSH Key**.

Fill out the form:

**Title**

```text
My Laptop
```

**Key Type**

```text
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:

```bash
ssh -T git@github.com
```

The first time you connect, you'll likely see:

```text
The authenticity of host 'github.com' can't be established.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
```

Type:

```text
yes
```

and press Enter.

If the setup is successful, GitHub will respond with:

```text
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.

```bash
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
```

Verify the configuration:

```bash
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:

```text
https://github.com/username/repository.git
```

Use the SSH URL:

```text
git@github.com:username/repository.git
```

Example:

```bash
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:

```bash
git remote -v
```

Example HTTPS remote:

```text
https://github.com/username/repository.git
```

Change it to SSH:

```bash
git remote set-url origin git@github.com:username/repository.git
```

Verify the update:

```bash
git remote -v
```

You should now see:

```text
git@github.com:username/repository.git
```

* * *

## Step 9: Test Git Operations

Try pulling changes:

```bash
git pull
```

Or pushing changes:

```bash
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:

```text
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 `.ssh` directory
    
*   You're using the correct GitHub account
    

Verify authentication again:

```bash
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:

```bash
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:

```bash
git remote -v
```

Expected output:

```text
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:

```bash
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.
