I had a lot of struggles getting agent forwarding to work properly in my setup with VS Code. Here are some things I learned.
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
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
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