Remote SSH Text Editor through Visual Studio Code

Overview

The following blog post will outline what is required in order to be able to remotely modify text files from a Visual Studio Code instance running from your workstation.

Requirements

Setup

The following sections will cover what is required in order to setup both your Visual Studio Code instance, as well as your running Linux instance. Ensure that you have root or administrative privileges to your running Linux instance.

Setting up Visual Studio Code

You are going to require the Remote VSCode extension for Visual Studio Code, which will enable for text file editing over a listening SSH tunnel.

Configuring Remote VSCode Extension

Modify your user or workspace settings (whichever you prefer), and specify the following properties.

settings.json — workspace configuration file for Visual Studio Code
settings.json — workspace configuration file for Visual Studio Code

Setting up your Linux instance over SSH

Connect to your running Linux instance over SSH, and ensure that the user account user has sudo or elevated privileges. Next, you are going to want to download the latest version of the rmate script from the GitHub repository that it resides in.

sudo wget -O /usr/local/bin/rmate https://raw.github.com/aurora/rmate/master/rmate
sudo chmod a+x /usr/local/bin/rmate

Setting up PuTTY (Windows)

Ensure that you have PuTTY installed on your machine, and that you can successfully establish a SSH connection to your running Linux instance through the tool.

Testing connectivity

Once you have successfully configured your PuTTY instance, connect to your running Linux instance and navigate to the file that you wish to have opened in Visual Studio Code. Run a separate Visual Studio Code instance, and ensure that the SSH listener is running in the background.

Usage

To open a remote file from your terminal into a running Visual Studio Code instance on your machine, simply run the following command.

root@arcanenet-2:/etc/nginx# rmate nginx.conf

--

--

Senior Software Engineer working in games. Experienced in C++, C#, and TypeScript.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luc Shelton

Luc Shelton

52 Followers

Senior Software Engineer working in games. Experienced in C++, C#, and TypeScript.