Git | Connecting to GitHub and Pushing Changes Using SSH on Windows

Connecting to GitHub and pushing changes using SSH on a Windows machine involves several steps:

  1. Generate SSH Key Pair
  2. Add SSH Key to GitHub Account
  3. Configure SSH for GitHub
  4. Clone Repository or Add Remote URL
  5. Commit and Push Changes

Step-by-Step Instructions

1. Generate SSH Key Pair

  1. Open Git Bash on your Windows machine.
  2. Generate a new SSH key pair by running:

    ssh-keygen -t rsa -b 4096 -C ""

    Replace with your GitHub email address. When prompted, save the key to the default location (/c/Users/your_username/.ssh/id_rsa) and optionally set a passphrase.

2. Add SSH Key to GitHub Account

  1. Copy the SSH key to your clipboard. You can use the following command to do this:

    cat ~/.ssh/ | clip
  2. Log in to your GitHub account.
  3. Go to Settings > SSH and GPG keys.
  4. Click New SSH key.
  5. Paste the copied SSH key into the key field and give it a descriptive title.
  6. Click Add SSH key.


3. Configure SSH for GitHub

  1. Ensure your SSH agent is running. Start the SSH agent by running:

    eval "$(ssh-agent -s)"
  2. Add your SSH private key to the SSH agent:

    ssh-add ~/.ssh/id_rsa

4. Clone Repository or Add Remote URL

If you haven’t cloned your repository yet, you can do so using SSH:

  1. Go to your repository on GitHub.
  2. Click on the Code button and copy the SSH URL (it looks like
  3. Clone the repository:

    git clone

If you already have a repository cloned using HTTPS and want to switch to SSH, you can change the remote URL:

  1. Navigate to your repository directory in Git Bash.
  2. Change the remote URL:

    git remote set-url origin

5. Commit and Push Changes

  1. Make your changes and stage them for commit:

    git add .
  2. Commit your changes:

    git commit -m "Your commit message"
  3. Push your changes to GitHub:

    git push origin main

    Replace main with the name of your branch if you’re working on a different branch.

Additional Tips

  • Verify SSH Connection: You can test your SSH connection to GitHub by running:

    ssh -T

    This should return a success message like Hi username! You've successfully authenticated.

  • SSH Key Management: If you manage multiple SSH keys, you can create a ~/.ssh/config file to specify which key to use for GitHub:

      User git
      IdentityFile ~/.ssh/id_rsa

What next ?

By following these steps, you should be able to connect to GitHub and push changes using SSH on your Windows machine.

This post is licensed under CC BY 4.0 by the author.