Skip to content
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

[Remote-SSH Bug]: SSH_AUTH_SOCK is getting stale over time #9819

Open
3 tasks done
hellt opened this issue Apr 24, 2024 · 4 comments
Open
3 tasks done

[Remote-SSH Bug]: SSH_AUTH_SOCK is getting stale over time #9819

hellt opened this issue Apr 24, 2024 · 4 comments
Assignees
Labels
ssh Issue in vscode-remote SSH

Comments

@hellt
Copy link

hellt commented Apr 24, 2024

Is there an existing issue for this bug?

  • I have searched the existing issues

Required Troubleshooting Steps

  • I have followed these troubleshooting steps
  • I have tried both values of the remote.SSH.useLocalServer setting

Connect Locally

It connects successfully

->

Over time (I presume when the system goes to sleep and ssh connection to the remote gets disconnected), the ssh agent socket file - $SSH_AUTH_SOCK - starts to point to a non-existing file.

Example:

❯ file $SSH_AUTH_SOCK
/tmp/ssh-XXXX5pnG8t/agent.662781: cannot open `/tmp/ssh-XXXX5pnG8t/agent.662781' (No such file or directory)

This, in its turn, makes the SSH agent unavailable in the remote system and the only workaround is to "kill the remote server" which is very annoying.

Expected Behavior

SSH_AUTH_SOCK refreshes when the remote is reconnected.

Steps To Reproduce

  1. use SSH agent forwarding
  2. make system go to sleep
  3. after reconnecting to the remote check if the file $SSH_AUTH_SOCK resolves to an existing file

Remote-SSH Log

Remote-SSH Log

[09:23:17.216] Log Level: 2
[09:23:17.222] VS Code version: 1.88.0
[09:23:17.222] Remote-SSH version: remote-ssh@0.110.1
[09:23:17.223] win32 x64
[09:23:17.228] SSH Resolver called for "ssh-remote+example", attempt 1
[09:23:17.229] "remote.SSH.useLocalServer": false
[09:23:17.229] "remote.SSH.useExecServer": true
[09:23:17.229] "remote.SSH.showLoginTerminal": false
[09:23:17.229] "remote.SSH.remotePlatform": {"example":"linux"}
[09:23:17.229] "remote.SSH.path": C:\Windows\System32\OpenSSH\ssh.exe
[09:23:17.229] "remote.SSH.configFile": undefined
[09:23:17.230] "remote.SSH.useFlock": true
[09:23:17.231] "remote.SSH.lockfilesInTmp": false
[09:23:17.231] "remote.SSH.localServerDownload": auto
[09:23:17.231] "remote.SSH.remoteServerListenOnSocket": false
[09:23:17.231] "remote.SSH.showLoginTerminal": false
[09:23:17.231] "remote.SSH.defaultExtensions": []
[09:23:17.231] "remote.SSH.loglevel": 2
[09:23:17.232] "remote.SSH.enableDynamicForwarding": true
[09:23:17.232] "remote.SSH.enableRemoteCommand": true
[09:23:17.232] "remote.SSH.serverPickPortsFromRange": {}
[09:23:17.232] "remote.SSH.serverInstallPath": {}
[09:23:17.238] SSH Resolver called for host: example
[09:23:17.238] Setting up SSH remote "example"
[09:23:17.242] Using commit id "5c3e652f63e798a5ac2f31ffd0d863669328dc4c" and quality "stable" for server
[09:23:17.245] Install and start server if needed
[09:23:17.254] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[09:23:17.288] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[09:23:17.292] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 63708 example bash
[09:23:17.294] Terminal shell path: C:\Windows\System32\cmd.exe
[09:23:18.521] > �]0;C:\Windows\System32\cmd.exe�
[09:23:18.521] Got some output, clearing connection timeout
[09:23:20.686] > ac26998f326f: running```

Anything else?

Related issue - #9767 - was closed because of the workaround, but doesn't actually provided a long term fix.

This issue is meant to track the cause of the issue.

/cc @danielhass

@hellt hellt added the ssh Issue in vscode-remote SSH label Apr 24, 2024
@danielhass
Copy link

@hellt thanks for re-opening this as a new issue!

@djobin
Copy link

djobin commented May 16, 2024

We are seeing same behavior. From Windows or MacOS VS Code client (latest version). We connect to a Linux RHEL8 host with ssh agent forwarding. First remote-ssh connection succeeds. Then, if you "Developer: Reload Window" or if you "Close Remote Connection" and reconnect again, the env var $SSH_SOCK_AUTH refers to an invalid socket file. You can confirm this by starting a new terminal and typing file $SSH_SOCK_AUTH. You will then get an error that looks like this /tmp/ssh-Axx5CAtS6J/agent.1749639: cannot open '/tmp/ssh-Axx5CAtS6J/agent.1749639' (No such file or directory)

Furthermore, if you use SSH to acces git repos within the SCM, you will get "access denied"

The "solution" is that you have to kill remote vscode server and reconnect again to have succesfull forwarding.

Workarounds I found was :

  • Downgrade Remote-SSH extension to v0.102.0 (+1 year old)
  • Set "remote.SSH.useExecServer": false in settings.json

VS Code Version: 1.89.1
Remote-SSH Version: v0.110.1

@kavehv
Copy link

kavehv commented May 20, 2024

The workaround specified to set "remote.SSH.useExecServer": false makes things work again for me.

@OmNamasi
Copy link

I faced this issue on vscode on the remote machine, where was I fixing the tmux.conf (pertaining to SSH key forwarding) & noticed this SSH_AUTH_SOCK stale issue. setting "remote.SSH.useExecServer": false resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

6 participants