Why ssh connection to host via VS code is getting disconnected every 5-10 mins?

Sudeepta kumar 0 Reputation points
2025-12-08T08:21:14.63+00:00

ssh connection to host via VS code is getting disconnected every 5-10 mins. How to fix this?

image (3)

Developer technologies | Visual Studio | Extensions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 1,205 Reputation points Microsoft External Staff
    2025-12-09T13:07:53.2833333+00:00

    Thanks for sharing the details
    Your SSH session in VS Code is disconnecting because the server closes idle connections. Please follow the steps below to fix the issue:

    1. Update the SSH server keep-alive settings:

    Edit sshd_config and add:

    ClientAliveInterval 60

    ClientAliveCountMax 5

    Then restart SSH and sudo systemctl restart sshd

    1. Enable VS Code keep-alive:

    Add this in VS Code settings "remote.SSH.keepalive": 30

    1. Update your local SSH config:

    ServerAliveInterval 60, ServerAliveCountMax , TCPKeepAlive yes

    1. Ensure stable network/VPN connection.

    These settings prevent idle-timeout disconnections and keep your VS Code Remote-SSH session active.

     

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.