Skip to content

Instantly share code, notes, and snippets.

@Youngermaster
Last active April 14, 2024 09:36
Show Gist options
  • Save Youngermaster/4fec4af95888b1b789856a46832cdc32 to your computer and use it in GitHub Desktop.
Save Youngermaster/4fec4af95888b1b789856a46832cdc32 to your computer and use it in GitHub Desktop.
How to use SSH with Git and ssh-agent on Windows

How to use SSH with Git and ssh-agent on Windows

Acknowledgement

I used this Blog as a base for this:

Enabling SSH agent

Open a powershell terminal as administrator and run the following to have ssh-agent available.

# Have SSH agent start automatically
Get-Service ssh-agent | Set-Service -StartupType Automatic

# Start SSH agent now
Start-Service ssh-agent

# Should work successfully
Get-Service ssh-agent

Configure git to use Windows SSH

# Tell git to use ssh.exe
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

Load keys into SSH agent

Copy your keys into a folder that ssh-agent can access. Anywhere in the $HOME/.ssh should be ok.

Then add the key to ssh-agent. You will be prompted for a password and ssh-agent will remember it for you.

# Add all the private keys you want, either `id_ed25519` or `rsa` types:
ssh-add "C:\Users\Juan Manuel Young H\.ssh\id_ed25519_key"
ssh-add "C:\Users\Juan Manuel Young H\.ssh\rsa_key"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment