question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSH Agent Forwarding not working with Remote SSH on MacOS (still a problem)

See original GitHub issue

The 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:

  1. set up ssh config with a host you want to forward your ssh agent keys to and set ‘ForwardAgent yes’
  2. Connect via terminal ssh and perform an operation requiring your forwarded key (in my case, ssh -T git@github.com)
  3. launch VSCode and validate that $SSH_AUTH_SOCK is set
  4. 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:open
  • Created 2 years ago
  • Reactions:4
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
davibecommented, Jun 4, 2022

Same issue here, closing and recreating the terminal fixes it, but terminals cerated when vscode starts have a stale SSH_AUTH_SOCK

0reactions
meganroggecommented, Dec 6, 2022

Yeah the env var info widgets never appear for me in WSL

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSH Agent Forwarding not working with Remote SSH ... - GitHub
In short, ssh agent forwarding does not work in VSCode, despite working just fine when I SSH in via the terminal. It seems...
Read more >
Why is ssh agent forwarding not working? - Server Fault
It turns out my key was not in the agent, and this fixed it: OS X: ssh-add -K. Linux/Unix: ssh-add -k. You can...
Read more >
SSH Agent Forwarding not working even when using `ssh
After SSH into the remote/intermediate host, do this to verify that the Agent Forwarding is in effect: remote-host$ echo $SSH_AUTH_SOCK /tmp/ ...
Read more >
github - SSH Agent Forwarding not working - Stack Overflow
Check SSH Agent forwarding is enabled by running following command. It should list a socket file ... git ls-remote --heads git@github.com:account/repo.git.
Read more >
SSH Agent not working for applications other than Terminal
I have tried with MacOS Mojave on another Macbook Air installing Atom and the plugins fresh and it also doesn't work. The SSH...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found