Getting SSH agent passthrough working with VS code
(Updated 2023-04-24)
I had frustrations getting SSH agent passthrough working with VS code such that when I was remoted onto a linux box and working with git, I wasn't able to use the git functions inside code as the auth was failing.
Doing the following worked for me at an administrator powershell prompt on your own machine
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Once you've got pageant or similar loading your keys then this should all work. You might need to add entries similar to below into your local ssh config file to ForwardAgent yes:
Host remotehostname
User yourusername
ForwardAgent yes
Also make sure that you've got your ssh identity loaded
Use the following to list identities
'ssh-add -l'
and the following to add your id_rsa key
'ssh-add ~/.ssh/id_rsa'
Troubleshooting
"ssh -V" to get the version.
Try using "ssh -vT git@github.com" to test the forwarding.
Due to bugs in the version of openssh v8.6p1 shipped with Windows 11 22H2, I only got this to work using a more recent release https://github.com/PowerShell/Win32-OpenSSH/releases. So if you have problems where once connected you can see the error "get_agent_identities: ssh_fetch_identitylist: communication with agent failed" when doing "ssh -vT git@github.com" to test the forwarding, try updating. I tested and worked with v9.2.2.0p1-Beta.
Comments
Post a Comment