1

When I SSH into my development VM and want to open something in VSCode, I cannot do so from the command line. Obviously that makes sense because the code command runs on the remote server which has no idea about the host.

When running code from a VSCode integrated terminal using the SSH plugin will however open another VSCode window for that remote folder.

Is it possible to run a command (like code ./foldername) on my SSH connection and have that command do something on the host (e.g. open VSCode)? From a normal terminal window over SSH? Does such a thing exist?

3
  • 1
    My development environment is inside a virtual machine. I use vscode locally and connect to the vm using ssh. I'm essentially trying to achieve a hand-rolled wsl2
    – David Alsh
    Commented Apr 3, 2021 at 3:52
  • That makes sense, thanks
    – David Alsh
    Commented Apr 3, 2021 at 4:21
  • Still unclear: Where do you want VSCode to run, where is the project, where do you want to enter the command? (Add to your comment @harrymc for me to be notified.)
    – harrymc
    Commented Apr 3, 2021 at 8:48

1 Answer 1

0

A solution is described in the Microsoft article Remote Development using SSH.

This solution involves running a VScode server on the remote machine and a development VScode instance on the client machine.

The exact process is described in the article (and may change in the future). It requires installing on the server VScode the Remote Development extension pack. On the client VScode you start by selecting "Remote-SSH: Connect to Host..." from the Command Palette (F1) and using the same user@hostname from the SSH connection.

The article illustrates the process with the following diagram:

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .