microsoft / microsoft/vscode-remote-release

VSCode Remote-SSH drops connection at exactly 20 seconds despite SSH working fine

Open
#10,987 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

ssh
Dominant language
Dockerfile
Stars
4.2k
Forks
469
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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

  1. 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

  1. 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"
    }
    }
  2. Server-side Configuration

Modified /etc/ssh/sshd_config:
ClientAliveInterval 60
ClientAliveCountMax 3
TCPKeepAlive yes

Restarted SSH service

  1. 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.``

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the generated piped SSH command shown in the report, then compare it with the direct SSH tests and the Remote-SSH settings listed. Trace the extension's handling of that command and its 20-second connection lifecycle. Done means the Remote-SSH connection remains stable beyond 20 seconds while the same SSH keep-alive configuration continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
devtools, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.