Sphere
Log in Join
☆ 8

VS Code Remote-SSH keeps disconnecting after ten minutes idle

VS Code 1.87 with Remote-SSH 0.108, connecting to Ubuntu 22.04 over a corporate VPN. Every ten minutes of inactivity the connection drops and I have to reload the window, which loses my terminal state. ServerAliveInterval 60 is already in ~/.ssh/config. What else can I do? It's been slowly driving me up the wall. I added a keepalive setting in VS Code too but I'm not sure it's actually taking effect, since the drop happens at exactly the same interval every time.

⚑ Report

4 replies

☆ 0
P paper83 ·2026-10-05#1

Check both sides: ServerAliveInterval 60 plus ServerAliveCountMax 3 in your local SSH config, and ClientAliveInterval in the server's /etc/ssh/sshd_config. Remote-SSH also has remote.SSH.keepAliveInterval — set it to something under your VPN's idle timeout. You need the daemon-side change too if you can get IT to make it.

⚑ Report
☆ 0
F ferret21 ·2026-10-08#2

I added ServerAliveCountMax and the VS Code setting. Still drops. I suspect the VPN has a hard ten-minute cutoff regardless of keepalives, since it's the same number every time. Changing ServerAliveInterval to 20 didn't move the drop time at all, which is what makes me think it's the tunnel.

⚑ Report
☆ 0
S stack ·2026-10-15#3

If the VPN drops the TCP session itself, SSH keepalives won't help because they get killed at the tunnel. As a workaround, run something that generates traffic — a tmux session with watch -n 30 date in it. Ugly, but it keeps the connection alive.

⚑ Report
☆ 0
D duct90 ·2026-10-18#4

We switched to Tailscale for exactly this reason — no VPN idle timeout problems and Remote-SSH stays up for hours. If you're stuck with the corporate VPN, ask IT what the idle timeout is and set your keepalive intervals to half of it.

⚑ Report
Log in to reply.