DEV Community

John
John

Posted on • Edited on

Visual Studio Code on a remote server

These days, it is easy to set up a web server where you can program remotely using virtually any client device.

It is not difficult to do this using secure shell alone, but here are a few methods that can enhance this experience using the Visual Studio Code editor.

Definitions

  • CL = Command Line
  • FS = File System

Pre-Requisites

This tutorial assumes that you are already famaliar with using secure shell (SSH).

You should at least be famaliar with logging into a remote server using key-based authentication.

Method 1 : code-server

Code-server creates a web server with an instance of a web version of Visual Studio Code that you can access via a browser.

  1. Install code-server on your server.
  2. Access server's CL via SSH.
  3. On server, run code-server <path to workspace or directory>.
  4. You can access server's FS and CL through password-secured web interface at :8443

Method 2 : sshcode

Sshcode works similarly to code-server (it's actually built on top of it) but uses a client program to set up the web server. Additionally, if you're using chrome, it will open a customized window with Visual Studio Code keybinding in tact.

  1. Install chrome and sshcode on client
  2. On client, run sshcode <user>@<serveraddress>
  3. Access server's FS and CL through chrome window.

Method 3 : Visual Studio Code

  1. Install Visual Studio Code on client
  2. Install Remote - SSH extension
  3. From extenison menu, connect @
  4. Access server's FS and CL through Visual Studio Code
  5. From extension menu, tunnel ports from server to client.

Next Steps

To supplement the above methods, you may want to learn about:

  • mounting file remote folders locally and using any editor you want using sshfs
  • accessing other resources on your remote maching via tunneling.
  • mitigating unstable remote [mobile] connections with mosh.
  • customizations and pitfalls of above programs by reading their documetion.

Top comments (0)