How to setup SSH Authentication to GitHub in Windows 10

This post explains how to setup SSH Authentication to GitHub in Windows 10. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit.

Generate a new SSH key

  • Open Git Bash and run below command.
  •    
    ssh-keygen -t ed25519 -C "replace_with_email_id"
     

  • Press Enter on "Enter a file in which to save the key" prompt. This accepts the default file location.
  •  
    Enter a file in which to save the key (/c/Users/you/.ssh/id_algorithm):[Press enter]
         

  • Type secure passphrase for below prompts.
  •    
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]
     

    Add SSH key to the ssh-agent

    Open Powershell Prompt with Admin Privileges and run below commands.

  • Allow ssh-agent to be manually started, by default the ssh-agent service is disabled in Windows 10.
  •    
    Get-Service ssh-agent | Set-Service -StartupType Manual
     

  • Start the ssh-agent service.
  •    
    Start-Service ssh-agent
     

  • Check status of ssh-agent service.
  •    
    Get-Service ssh-agent
     

  • Navigate to .ssh directory.
  •    
    cd $home\.ssh
     

  • Load key files into ssh-agent.
  •    
    ssh-add id_ed25519
     

    Add new SSH key to GitHub Account

  • Open Git Bash and navigate to .ssh directory.
  •    
    cd ~/.ssh
     

  • Copy SSH public key(output of below command)
  •    
    cat id_ed25519.pub
     

  • Login to GitHub Account and in the upper-right corner of any page, click on profile photo, then click Settings.
  • In the user settings sidebar, click SSH and GPG keys
  • .

  • Click New SSH key
  • Provide suitable title and click on Add SSH Key.
  • Test SSH Connection

    Open Git Bash and run below command you should output similar to as shown below.

       
    ssh -T git@github.com
    
    # Output
    Hi username! You've successfully authenticated, but GitHub does not provide shell access.
     

    Category: Linux