Skip to content

Instantly share code, notes, and snippets.

@gunhaxxor
Last active January 13, 2021 15:17
Show Gist options
  • Save gunhaxxor/23cdf67cd358a7b5da1a572880a78144 to your computer and use it in GitHub Desktop.
Save gunhaxxor/23cdf67cd358a7b5da1a572880a78144 to your computer and use it in GitHub Desktop.
SSH agent forwarding on windows

SSH agent forwarding (win 10)

I had a lot of struggles getting agent forwarding to work properly in my setup with VS Code. Here are some things I learned.

Useful resources

Read this one first: https://docs.github.com/en/free-pro-team@latest/developers/overview/using-ssh-agent-forwarding Also good read: https://code.visualstudio.com/docs/remote/troubleshooting#_setting-up-the-ssh-agent

Lessons learned

Make sure ssh-agent is running

Configure it to start on login like so:

# Make sure you're running as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

Make sure the hosts in your config is added to SSH-agent when connecting

It was not clear to me that this didn't happen automatically. You must provide the AddKeysToAgent yes row in your config file. Example:

AddKeysToAgent yes 
Host github.com
  User git
  HostName github.com
  IdentityFile ~/.ssh/keyfile.pem
  ForwardAgent yes
Host example-server
  HostName example.com
  User user
  IdentityFile ~/.ssh/example-key.pem
  ForwardAgent yes
  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment