Remote Development Using DVT IDE for VS Code over SSH
Overview
This video explains how to set up DVT with the VS Code Remote-SSH extension.
Typically you run VS code on your Windows PC or laptop and connect over SSH to a powerful Linux machine where your source code is accessible.
Remote Development using SSH - https://code.visualstudio.com/docs/remote/ssh
Details
Introduction
The Visual Studio Code Remote SSH extension allows you to open a folder located on any machine that has a running SSH server. The typical use case is running the VS Code UI on a Windows PC or laptop and connecting to a Linux server machine. Once connected, DVT runs on the remote host, usually a workstation with lots of computing power where your source code is accessible.
Installing the Remote SSH Extension
The Remote SSH extension is a Microsoft proprietary product and is only available from within Visual Studio Code. Therefore, it is not bundled in the DVT distribution, which includes the open-source build called VS Codium. To install the extension, go to the Extensions view, search for ms-vscode-remote.remote-ssh
, and press the Install button.
Configuring a New SSH Host
Let's start by adding a new SSH host using the Command Palette. Type the SSH command to connect to the desired machine, and then choose a file where the connection configuration will be saved.
Next, we connect the current window to the host we've just added. At this point, the tool might ask for several connection details, like the SSH password or the OS type. However, these steps depend on the particular connection layout. For example, if using key authentication, the password would not be needed.
Now VS Code is connected to the remote system, as you can see in the bottom left indicator.
Installing the DVT Extension on the Remote System
Now let's focus on the Extensions view. Note that although the DVT extension is installed locally, it was not automatically installed on the remote system, and we need to explicitly install it.
Finally, let's configure the DVT license. Open the Settings UI from the Command Palette and search for DVT License Source. If you're using a licensed server, set the preference to port@host
. Note that the server must be accessible from the remote machine. Now, if you have a license file, set the preference to the file content surrounded by three curly brackets.
To start working on our project on the remote machine, we simply use the DVT: Create a Project...
command and fill in the project's location.
Tips and Tricks for Working with Remote SSH
Checking Connection Status
You can always see the connection status in the bottom left indicator. Clicking on it gives you quick access to Remote SSH related commands, like connecting to a host, closing the active connection, or configuring the extension settings.
Automating Extension Installation
To automate the extension installation process, look for the Default Extensions preference and add amiq.dvt
to the list. Now, every time you connect to a new machine, DVT will be automatically installed.
Handling Remote Servers Without Internet Access
Furthermore, if the remote server does not have access to the internet, search for Download Extensions Locally preference and enable it. Extensions will be downloaded on your local machine and then installed on the server over the SSH tunnel.
Using the SSH Targets View
An alternative way to connect to a remote server is from the SSH Targets view located in the Remote Explorer activity. It shows a list of all the configured hosts and offers quick access to previously opened folders. Simply click the floating folder icon to open a new window and connect it to the selected host.
Setting Environment Variables
Finally, mind that the environment variables on the remote machine are not inherited from the machine where you started VS Code. If you need to have specific variables set regardless of the machine where VS Code runs, open the Settings UI and look for DVT Environment Variables. The list of variables specified here will be injected into the environment during the extension's runtime for running language servers, tasks, or commands from the built-in terminal.