Finally Tackled My VSCode Remote SSH Disk Bloat—Thanks to a Reddit user and a Smart Bash Script
If you frequently use VSCode’s Remote SSH extension, you may have noticed how the ~/.vscode-server directory quietly accumulates outdated server binaries, extension caches, and temporary files resulting on a (at times) very large folder. I’ve run into this issue - especially on smaller instances where storage is at a premium. Today, I tried a cleanup script shared by u/XDflight_Official on Reddit (see here), with great results.
The script doesn’t deeply analyze which extensions or server versions are actively in use or required by your current VSCode setup - it uses filename parsing and version heuristics to identify and remove older VSCode server versions and extension folders. It resets the lru.json file to reference the latest server version, purges cached VSIX files, and deletes temporary .vsctmp extension folders. For extensions, it keeps only the most recent version of each by name, removing older duplicates. It’s a direct and effective approach, but not foolproof—there’s no validation against active sessions, so it’s best run when no remote VSCode instances are connected. Personally I run this with cron every night when I know, most probably, there will be no vscode connections to the server.
As you can see on the original Reddit post, there have been multiple GH issues raised for this issue. Issue #7963 shows that VSCode does attempt to limit the number of server versions to five, but this threshold isn’t configurable and often isn’t triggered before users hit disk limits. The discussion also reveals that the CLI manages server versions but retains older ones without user control. Several people have requested a customizable retention policy—such as setting the max number via environment variables—which is now under consideration for future updates. This aligns with broader concerns raised in Issue #6429, where shared environments like university servers suffer from excessive storage and RAM usage due to redundant server installs.
I ran the script on a dev box that’s had intermittent issues and it has worked fine, with no oversized folder anymore and everything still stable and as efficient/ fast as before.
Major credits go to u/XDflight_Official for sharing a solution that’s technically sound, easy to run, and just plain useful. If you’re managing remote environments and noticing disk bloat or performance degradation, this script is worth adding to your workflow—just be sure to run it with care and monitor the results - I'm quite sure it will be more than fine, but I have only used it for a couple of days so far. Hopefully, with enough community feedback, VSCode will offer more robust housekeeping options natively.
Enjoy!