VSCode Remote-SSH drops connection at exactly 20 seconds despite SSH working fine
Environment
VSCode Version: 1.100.2 VSCode Insiders Version: 1.101.0-insider (also tested, same issue) Remote-SSH Extension Version: v0.120.0 Local OS: Windows 10 (64-bit) Remote OS: Ubuntu (Linux 6.8.0-51-generic) SSH Client: OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
Issue Description VSCode Remote-SSH consistently drops the connection at exactly 20 seconds after establishing connection, even though direct SSH connections work perfectly fine for extended periods. Steps to Reproduce
Configure SSH with aggressive keep-alive settings Connect to remote host via VSCode Remote-SSH Connection drops at exactly 20 seconds with error: client_loop: send disconnect: Connection reset
SSH Configuration Used Host [remote-host] HostName [remote-ip] User [username] IdentityFile ~/.ssh/id_ed25519 ServerAliveInterval 5 ServerAliveCountMax 24 TCPKeepAlive yes ConnectTimeout 60 Extensive Testing Performed
- Direct SSH Test - WORKS bash# Test 1: Basic 30-second connection echo "sleep 30; echo 'Survived 30 seconds'" | ssh -F ~/.ssh/config [remote-host] sh
Result: SUCCESS - completed without disconnection
Test 2: Extended connection with output
ssh [remote-host] "while true; do echo -n '.'; sleep 1; done"
Result: SUCCESS - ran for 2+ minutes without disconnection
- VSCode Settings Attempted json{ "remote.SSH.configFile": "~/.ssh/config", "remote.SSH.connectTimeout": 120, "remote.SSH.useLocalServer": false, "remote.SSH.lockfilesInTmp": true, "remote.SSH.serverInstallPath": { "[remote-host]": "/home/[username]/.vscode-server-custom" } }
- Server-side Configuration
Modified /etc/ssh/sshd_config: ClientAliveInterval 60 ClientAliveCountMax 3 TCPKeepAlive yes
Restarted SSH service
- Troubleshooting Steps Taken
✅ SSH key authentication working (no password prompts) ✅ Cleaned all .vscode-server directories multiple times ✅ Killed all VSCode server processes ✅ Tested with fresh install (no workspace opened) ✅ Tested with VSCode Insiders (same 20-second timeout) ✅ Created SSH wrapper scripts to force keep-alive options ✅ Verified no firewall/network issues (direct SSH works) ✅ Tested from multiple client machines
Key Findings Connection Timeline (from logs): [timestamp] [server] Server started [timestamp+20s] > client_loop: send disconnect: Connection reset Exactly 20 seconds every time Pattern Observed:
VSCode establishes connection successfully Server starts normally At exactly 20 seconds, connection drops This happens regardless of:
Keep-alive settings Whether a workspace is opened Clean vs existing installation Different VSCode versions
Critical Observation: The issue appears specific to how VSCode Remote-SSH handles piped SSH commands: Generated SSH command: 'type "C:\Users[user]\AppData\Local\Temp\vscode-linux-multi-line-command-[host]-[id].sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D [port] -F "~/.ssh/config" "[host]" sh' When SSH is used with piped input through VSCode, it disconnects at 20 seconds. Direct SSH connections without piping work indefinitely. Expected Behavior Connection should remain stable indefinitely, respecting SSH keep-alive settings. Actual Behavior Connection drops at exactly 20 seconds, requiring constant reconnection attempts. Impact Makes VSCode Remote-SSH unusable for development on affected systems. Additional Information
No antivirus/firewall blocking (direct SSH works) Not a network timeout (direct SSH maintains connection) Not workspace-related (happens without opening any folder) Appears to be a hardcoded timeout in the extension's SSH handling Multiple reconnection attempts show identical behavior
Potential Root Cause The 20-second timeout appears to be specific to piped SSH commands in the Remote-SSH extension, as direct SSH connections with the same configuration maintain connectivity indefinitely.``
Try this "remote.SSH.useExecServer":false
remote.SSH.useExecServer
this fixed it for me
Try this
"remote.SSH.useExecServer":false
This did NOT work for me. continue to have rapid disconnects. As others mentioned, ssh is fine, it's vscode or it's ssh extension that is messing up consistently here. I'm possible to work with 20 second disconnects.