SSH Agent Forwarding not working with Remote SSH on MacOS (still a problem)
See original GitHub issueThe title is the same as microsoft/vscode-remote-release#2671 because I’m having precisely the same problem, and that issue was closed without a resolution. In short, ssh agent forwarding does not work in VSCode, despite working just fine when I SSH in via the terminal. It seems to be due to a stale / cached SSH_AUTH_SOCK
.
The workaround suggested in microsoft/vscode-remote-release#2671 no longer works, but a minor modification does it for me. See below.
VSCode Version:
Version: 1.53.2
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:45:54.515Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin 20.6.0
Local OS Version: MacOS 11.6.1
Remote OS Version: Debian GNU/Linux 10 (buster) (GNU/Linux 4.19.0-18-cloud-amd64 x86_64)
Remote Extension/Connection Type: SSH
Steps to Reproduce:
- set up ssh config with a host you want to forward your ssh agent keys to and set ‘ForwardAgent yes’
- Connect via terminal ssh and perform an operation requiring your forwarded key (in my case,
ssh -T git@github.com
) - launch VSCode and validate that $SSH_AUTH_SOCK is set
- Connect via Remote-SSH, then use the VSCode terminal to run
ssh -T git@github.com
. This time, I receive a permission denied error.
Does this issue occur when you try this locally?: NA Does this issue occur when you try this locally and all extensions are disabled?: NA
Possible cause
The environment variable SSH_AUTH_SOCK
appears to be stale. A workaround is to run
export SSH_AUTH_SOCK=$(ls -t /tmp/ssh-**/* | head -1)
which sets the socket to the newest one. Note that this workaround is quite fragile, as I had to modify the previous workaround to make it work now.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:21 (9 by maintainers)
Top GitHub Comments
Same issue here, closing and recreating the terminal fixes it, but terminals cerated when vscode starts have a stale SSH_AUTH_SOCK
Yeah the env var info widgets never appear for me in WSL