Skip to content

Interacting with serve with ease via VSCode

This post consists of the following parts:

  • How to browse files on serve interactively using VSCode
  • Useful shortcuts
  • Common bugs and how to fix

Serve is usually a share space where multiple users sharing the computational resources. Therefore, it is important to remember that the server can go down,… So, it’s important to backup your work, especially the codes, via Github, for example. For heavy items like the model weights or private things like API keys, you can ignore them by using git ignore.

How to browse files on serve interactively using VSCode Remote SSH

Prequisite: You need to set up basic things like public and private keys with the server before this.

In this box, select Show and Run Commands:

Search File > Open folder as circled red in this image:

Click on it, paste in the path and then press OK.

Now, on the left panel of VSCode, you may see something like this

Now, you can right click a folder or a file and options like Download, Cut, Copy, will pop up as in the following figure:

The Copy Path option is quite useful for me, as it give the whole complete path of a file or folder


Useful Visual Studio Code shortcuts

🔎 Navigation

ActionWindows / LinuxmacOS
Quick file openCtrl + PCmd + P
Go to symbol in fileCtrl + Shift + OCmd + Shift + O
Go to lineCtrl + GCmd + G
Go to definitionF12F12
Peek definitionAlt + F12Option + F12
Go back / forwardAlt + ← / →Ctrl + - / Ctrl + Shift + -

✏️ Editing

ActionWindows / LinuxmacOS
Copy line down/upShift + Alt + ↓ / ↑Shift + Option + ↓ / ↑
Move line down/upAlt + ↓ / ↑Option + ↓ / ↑
Delete lineCtrl + Shift + KCmd + Shift + K
Duplicate lineShift + Alt + ↓Shift + Option + ↓
Toggle commentCtrl + /Cmd + /
Block commentShift + Alt + AShift + Option + A

🧠 Multi-Cursor (Super Powerful)

ActionWindows / LinuxmacOS
Add cursor above/belowCtrl + Alt + ↑ / ↓Cmd + Option + ↑ / ↓
Select next occurrenceCtrl + DCmd + D
Select all occurrencesCtrl + Shift + LCmd + Shift + L
Column selectionShift + Alt + DragShift + Option + Drag

🔍 Search & Replace

ActionWindows / LinuxmacOS
Find in fileCtrl + FCmd + F
Replace in fileCtrl + HCmd + Option + F
Global searchCtrl + Shift + FCmd + Shift + F
Replace in projectCtrl + Shift + HCmd + Shift + H

🧰 Productivity

ActionWindows / LinuxmacOS
Command paletteCtrl + Shift + PCmd + Shift + P
Quick fix / suggestionsCtrl + .Cmd + .
Rename symbolF2F2
Format documentShift + Alt + FShift + Option + F
Show problems panelCtrl + Shift + MCmd + Shift + M

🗂️ Tabs & Panels

ActionWindows / LinuxmacOS
Switch tabCtrl + TabCmd + Tab
Close tabCtrl + WCmd + W
Split editorCtrl + \Cmd + \
Toggle terminalCtrl + `Cmd + `

💡 Tip:
The single most powerful shortcut in VS Code is:

See also  SSH and SLURM basic and how to send a notification email upon job completion

Ctrl + Shift + P (or Cmd + Shift + P)
→ Opens the Command Palette where you can access almost everything.

Common bugs & how to fix

VSCode Remote SSH stops working while terminal still works

Once, I could log in to a linux server with terminal but not interactively via vscode. The log in worked before but suddenly stopped working after I tried to download a file from a location in the server that contains data (belong to public area). Normally, I don’t have such a problem when trying from my local account on the disk

This sounds like a classic SSH key or config issue triggered by something that changed during that file download session. Here are the most likely culprits:

VSCode Remote SSH and terminal use SSH differently. Your terminal likely uses a simpler SSH call, while VSCode’s Remote SSH extension has stricter requirements and its own connection process.

Most likely causes
  1. VSCode’s remote server files got corrupted VSCode installs a small server on the remote machine under ~/.vscode-server/. If the connection dropped mid-session during your download, those files may be partially written.

Fix: Log into the server using terminal. Then, delete and let VSCode reinstall them:

rm -rf ~/.vscode-server

Then reconnect from VSCode — it will reinstall automatically. Try this first, and if it doesn’t work, move to the next debugging alternatives.

1. The remote .bashrc / .bash_profile is now broken VSCode spawns an interactive login shell on the server, so it sources .bashrc and .bash_profile. If the file download modified or corrupted one of these files (e.g. appended something, or you ran a script that edited it), VSCode’s session will hang or fail — while a plain terminal ssh often tolerates this better.

See also  Paid Member Subscriptions: How to make all pages visible to non-login guests

Fix: Login to the serve via terminal and check:

tail -30 ~/.bashrc
tail -30 ~/.bash_profile

Look for anything unexpected at the bottom.

2. ~/.ssh/known_hosts got corrupted or the host key changed When you accessed that public data location, if it involved a different hostname, proxy jump, or if the server’s host key changed, VSCode will refuse to connect silently while your terminal might just warn you.

Fix: Remove the stale entry:

ssh-keygen -R your-server-hostname

Then try reconnecting in VSCode.

3. Disk quota exceeded on the server Downloading a file to your home directory may have pushed you over your quota. VSCode needs to write files to the server (its server-side agent, lock files, etc.) and will fail silently if it can’t.

Fix: Check your quota:

quota -s
# or
du -sh ~

5. SSH agent / key forwarding issue If your terminal uses a different key or SSH agent than VSCode, and the server’s authorized_keys was touched during that session, VSCode may be using a key that no longer works.

Fix: Check VSCode’s Remote SSH output log: F1 → Remote-SSH: Show Log — look for the exact error.

Quick diagnostic checklist
  1. Check VSCode’s SSH log (F1 → Remote-SSH: Show Log) — the actual error is almost always there
  2. Run quota -s on the server via terminal
  3. Check tail ~/.bashrc for unexpected changes
  4. Try rm -rf ~/.vscode-server on the server
  5. Try ssh-keygen -R hostname locally

The VSCode log will tell you exactly where it’s failing — that’s the fastest path to the root cause.

See also  How to Check GPU Access in SLURM Clusters

Leave a Reply

error: Content is protected !!