microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.21k stars 28.86k forks source link

SSH Remote fails to connect when there is a jump server #195092

Closed fourdim closed 9 months ago

fourdim commented 1 year ago

Does this issue occur when all extensions are disabled?: No

I've tried both stable and nightly version of VSCode and Remote-SSH.

So I believe it only relates to vscode itself.

Steps to Reproduce:

  1. Configure sshd config:
    
    Host host1
    HostName *
    Port 22
    IdentityFile *
    ProxyCommand D:/bin/cloudflared access ssh --hostname %h

Host host2 ProxyJump host1 HostName 192.168.254.203 Port 22 IdentityFile *

2. ssh to host2

VSCode Insider can connect at first. But when opening a terminal, the connection lost.

```log
[00:58:31.069] Remote server is listening on port 34891
[00:58:31.069] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":34891},"osReleaseId":"arch","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/run/user/1001","platform":"linux","connectionToken":"1a11a1aa-a1aa-1a11-1a1a-11a111a11111"},"installUnpackCode":""}
[00:58:31.071] Starting forwarding server. local port 1240 -> socksPort 1164 -> remotePort 34891
[00:58:31.072] Forwarding server listening on port 1240
[00:58:31.072] Waiting for ssh tunnel to be ready
[00:58:31.073] [Forwarding server port 1240] Got connection 0
[00:58:31.073] Tunneled port 34891 to local port 1240
[00:58:31.073] Resolved "ssh-remote+7b22686f73744e616d65223a224c616576617461696e227d" to "port 1240"
[00:58:31.074] Updating terminal environments: {}
[00:58:31.076] TELEMETRY: {"eventName":"resolver","properties":{"osReleaseId":"arch","arch":"x86_64","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","remoteInConfigFile":"1","gotUnrecognizedPrompt":"0","dynamicForwarding":"1","localServer":"0","didLocalDownload":"0","installUnpackCode":"0","outcome":"success"},"measures":{"resolveAttempts":3,"retries":1,"isExecServer":0,"timing.totalResolveTime":3004,"timing.preSshTime":11,"timing.scriptTime":2985}}
[00:58:31.077] ------

[00:58:31.087] [Forwarding server port 1240] Got connection 1
[00:59:01.083] Failed to set up socket for dynamic port forward to remote port 34891: Proxy connection timed out. Is the remote port correct?
[00:59:01.098] Failed to set up socket for dynamic port forward to remote port 34891: Proxy connection timed out. Is the remote port correct?
[00:59:08.093] ------

[00:59:08.093] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a224c616576617461696e227d", attempt 4, (Reconnection)

On the remote server host2:

$ lsof -i:34891
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    58023 fourdim   18u  IPv4 108510      0t0  TCP localhost:34891 (LISTEN)
node    58023 fourdim   22u  IPv4 108518      0t0  TCP localhost:34891->localhost:55246 (CLOSE_WAIT)
node    58023 fourdim   24u  IPv4 112414      0t0  TCP localhost:34891->localhost:59704 (ESTABLISHED)
node    58023 fourdim   25u  IPv4 110994      0t0  TCP localhost:34891->localhost:44576 (CLOSE_WAIT)
node    59162 fourdim   19u  IPv4 112416      0t0  TCP localhost:34891->localhost:59706 (ESTABLISHED)
roblourens commented 9 months ago

Does this still repro for you? If so, does setting `"remote.SSH.useExecServer": false" make a difference?