-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH Agent Forwarding not working with Remote SSH on MacOS (still a problem) #168202
Comments
Could it be an issue with needing to set an More details from the SSH Man(5) page:
|
Hmm.... I don't think that's the source of the problem. In particular, when I use I'm often able to trigger the issue this way:
Even weirder, after repeating steps 2 and 3 a few times, it's started using the correct socket after reload. |
What is |
I'm not able to trigger the issue right now, but |
Ok, I'm able to reproduce now. These are all run from within the VSCode terminal. Here's the initial situation: $ echo $SSH_AUTH_SOCK
/tmp/ssh-7G9TqKKzBp/agent.30503
$ ls -la /tmp/ssh*/**
srwxr-xr-x 1 xxx xxx 0 Feb 9 00:27 /tmp/ssh-9L8JuutTmn/agent.14198
srwxr-xr-x 1 xxx xxx 0 Feb 8 20:34 /tmp/ssh-jFxWY0hBUn/agent.16442
$ ssh -T [email protected]
[email protected]: Permission denied (publickey). We can see that the SSH_AUTH_SOCK variable is not pointed at an extant ssh agent. Now we apply the workaround: $ export SSH_AUTH_SOCK=$(ls -t /tmp/ssh-**/* | head -1)
$ ssh -T [email protected]
Hi mbmccoy! You've successfully authenticated, but GitHub does not provide shell access.
$ echo $SSH_AUTH_SOCK
/tmp/ssh-9L8JuutTmn/agent.14198 |
Most likely you went through reconnection and are now connecting through a different ssh process, this means the original ssh auth sock is invalid. The extension tries to redirect SSH_AUTH_SOCK to a different path that we control, seems like that didn't work here. Do you have If not can you share the Remote-SSH log from the output panel? |
Here's the output for a run where I just had this issue: https://gist.github.com/mbmccoy/331ba3674877b7c8769b482f78e467b7 Note that it does seem to have the correct agent in the logs ( This makes me suspect that the terminal caches the |
Do you have Is this a terminal from a previous session that was reconnected, or a fresh terminal? |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
I suppose I dropped the ball on getting back to you on this. No, I don't have any settings that are related to the terminal or remote set in my The ssh command does include the Not sure if it matters, but I do log in to the machine from a terminal outside of VSCode (with agent forwarding enabled). It doesn't always seem to cause the issue. I've updated to a recent version and I'm still occasionally seeing the issue.
|
Can you share the log from the Remote-SSH output channel? Basically we should be trying to rewrite your SSH_AUTH_SOCK to something like |
I believe I'm experiencing the same issue
it seems terminals that are re-opened after a window reload don't get their |
Was able to trigger this just now.
NOTE (added in edit) This is also consistent with @cdmistman 's observation that
Opening a new terminal after reload gives access. |
Same issue here, closing and recreating the terminal fixes it, but terminals cerated when vscode starts have a stale SSH_AUTH_SOCK |
The format of the fix above needed to be amended to match what I saw in my dev containers: ➜ ~ which ssh_vscode_fix
ssh_vscode_fix () {
export SSH_AUTH_SOCK=$(ls -t /tmp/vscode-ssh-auth-*.sock | head -1)
} |
hi any guess? update: if I add export SSH_AUTH_SOCK=$(ls -t /tmp/ssh-**/* | head -1) to my .profile and relaunch vscode, it reads it and git clone works fine, but I would like to omit this step, as it should work without it. |
I'd also like to throw my 2c in the mix. Sometimes when the window is reloaded, or some other state change happens the The symptom is similar to other people, not having a proper agent available. For context the local machine is an M1 Pro mac on 12.5.1, the host is a Ubuntu 20.04.4 LTS machine. This is using both |
What's supposed to happen is that when reloading the window, yes, the SSH_AUTH_SOCK in persisted terminals is incorrect. We set it to the I noticed that microsoft/vscode-remote-release#7642 was making this appear to work only because the old ssh process was still alive in the background, incorrectly. And there's something that does not work: we also use the terminal
This line in the log shows that we ran the |
env var info comes back when I reload after changing it with debug toggle auto attach env.mov |
It's possible we don't restore the state correctly for remote terminals only? |
Yeah the env var info widgets never appear for me in WSL |
You are awesome! +1 on this Update: unfortunately, it seems this works randomly. Now, |
Any update on this, it is getting very hard to work on development containers from windows (Windows host to WSL container). |
I've tried logging in with an old 1.6 vscode i had on a usb stick with static config. After logging in remote-ssh tells me the following symlinks are once again established: [13:58:44.035] Updating $SSH_AUTH_SOCK: ln -f -s "/tmp/ssh-XXXXiuO5un/agent.203985" "/run/user/1000/vscode-ssh-auth-sock-956309600" cleaning up all the remote.SSH.* settings and workarounds on 1.8 and logging in again with that version the symlinks started working again. |
Was experiencing this issue today. Can confirm that |
Same here right now! FWIW,
just before connecting works for me as well... |
Just in case anyone else has this issue, and Deleting UPDATE: it only fixed it temporarily 😢 Currently tried the |
At the remote, presumably? @micahcarroll |
I started having this issue on Windows as well. Previously, closing and reopening the terminal helped, but that stopped working. Setting |
I just experienced this on Windows 10 as well:
|
Deleting the remote |
I can confirm these steps solved it for me:
|
Both solutions worked for me: |
Setting The problem changes depending on how
|
I also faced the same issue on MacOS. I was able to fix it by deleting ~/.vscode-server on remote machine and then reconnecting via Remote SSH extension. |
The setting set which seems to work for my setup (macOS client -> Ubuntu host): {
"remote.SSH.enableAgentForwarding": true,
"remote.SSH.useLocalServer": false,
"remote.SSH.useExecServer": false,
"remote.SSH.remoteServerListenOnSocket": true,
} |
Thanks @lobantseff, works for me! I'll update here if anything changes on my side though. |
also fixes ubuntu -> ubuntu |
The workarounds mentioned here stops working for me (Windows client-> Linux Host) when I 'Reload Window'. UPDATE - Switching to the pre-release version of SSH Remote extension fixes this issue for me. |
Apart from these settings, I also had to add {
"terminal.integrated.persistentSessionReviveProcess": "never",
"terminal.integrated.enablePersistentSessions": false,
} To prevent the stale terminal session from being restored. After that, agent forwarding worked flawlessly. |
@joshspicer since you're very familiar with the SSH extension now, could you look into this issue and come up with recommendations to fix? Do we need to special case certain terminals to not revive the processes or something? |
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:
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:
ssh -T [email protected]
)ssh -T [email protected]
. 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 runwhich 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.
The text was updated successfully, but these errors were encountered: