Skip to content

Instantly share code, notes, and snippets.

@MarcHeiden
Last active June 10, 2022 16:34
Show Gist options
  • Save MarcHeiden/e0edaa8bcf29fd1f45c0ff391a464a8e to your computer and use it in GitHub Desktop.
Save MarcHeiden/e0edaa8bcf29fd1f45c0ff391a464a8e to your computer and use it in GitHub Desktop.

Github SSH Setup for Windows

Generating a new SSH key

To generate a new ssh key with the Ed25519 algorithm as recommended in the GitHub Docs paste the following powershell commmand:

> ssh-keygen -t ed25519 -C "comment of your choice"

Adding the SSH key to the ssh-agent

  1. Set the Startup Type of the ssh-agent to Manual

    > Get-Service -Name ssh-agent | Set-Service -StartupType Manual
  2. Start the ssh-agent

    > Start-Process ssh-agent
  3. Add the private key to the ssh-agent

    > ssh-add ~/.ssh/id_ed25519
  4. Set the Windows OpenSSH Client as the default SSH Client to use the ssh-agent configuration

    > git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe

Adding the SSH Key to the GitHub Account

  1. Copy the public key

    > cat ~/.ssh/id_ed25519.pub | clip
  2. Go to your Github Account Settings and add a new SSH key with a suiting title (for example the PC Name) and paste the public key.

Testing the SSH Key

  1. Verify if the SSH Key is loaded into SSH

     > ssh-add -l

    If everything worked you should see the public key fingerprint.

  2. Verify the connection to GitHub

    > ssh -T git@github.com

    After accepting the fingerprint you should see a message containing: You've successfully authenticated.

In case that anything went wrong check out the GitHub docs.

Adding the ssh-agent to Startup

  1. Press Windows Button + R and paste the following:

    shell:startup
    
  2. In the opened folder create a symlink to the ssh-agent

    > New-Item -ItemType SymbolicLink -Path "Enter Path to Startup Folder Here" -Target "C:\Windows\System32\OpenSSH\ssh-agent.exe"

Ready 🚀

That's it. You should now be able to push to repos without being prompted to type your username or password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment