Posts Working on Remote Projects with Visual Studio Code
Post
Cancel

Working on Remote Projects with Visual Studio Code

I really like using Visual Studio Code when it comes to working on both Windows and Linux projects, but the issue is that there are times when Im working on a project in a VM and don’t have a desktop environment to use VS code. There are also times when I away from my personal laptop or desktop and I don’t have access to my Visual Studio Code desktop application and I need to make some changes to my coding projects, blog, or home lab. A good workaround to these is using Visual Studio Code Remote-SSH extension to access my headless VMs using SSH or when Im completely away and need to use something like my own self-hosted VS code server.

Gitea

I try to keep my coding projects off of my personal PC or work laptop to make sure that I have a central location for my projects. I do this by self-hosting my own Gitea docker on my Synology NAS with a mounted folder for my coding projects and security payload/tool development. The reason I use Gitea is so I can not only utilize git to track revisions, but also have a web interface for viewing all my projects and branches Im currently working on. All this helps me ensure that I’m pushing clean code and merging working releases into the master branch. Since some of my projects are sensitive and I don’t want them to be scanned by AV vendors or even used by others I can use my Gitea to control what tools and payloads I release to the public.

Coding Environment

I use a mixture of Windows virtual machines and Linux docker/VMs depending on the project and if it needs to access kernel functions or specific OS version. When it comes to working on coding projects on a Windows virtual machine I usually just RDP or use VS Code directly in the VM. When it comes to working on Linux coding projects I tend to SSH from host machine using VS Code. When I need a specific version of GCC or another compiler I will usually install docker in a Linux VM or just SSH directly to my Synology NAS and use a docker container on there. Once I complete a feature in my coding project I usually push these changes to my personal Gitea instance before I decide to release it publicly.

Remote-SSH

One of the most useful extensions that I use is in Visual Studio Code is Remote-SSH. This extension is developed and maintained by Microsoft and is super helpful. I use this extension a quite often when connecting to my VMs to compile, review, and modify my code. Since Visual Studio Code is light weight there is no need to reinstall all the extension or packages need on my host when I can just SSH into the environment that Im working in then have all the extension already prepared. This helps keep my projects stable, no file duplicates, uniformity when using a VS Code to connect to it, and another nice caveat is that SSH provides some security when developing.

Once you install Visual Studio Code and the Remote-SSH extension you need to first add a new host before connecting.

My Remote-SSH Setup

Since I use Windows 10 as my main OS with Visual Studio my SSH config for Remote-SSH is stored at: C:\Users\Noah Tongate\.ssh\config

My configuration for one of my machines looks similar to the following:

1
2
3
4
Host Blog-Server
  HostName 192.168.5.9
  User root
  IdentityFile "C:\Users\Noah Tongate\Documents\Access\SSH Keys\priv-key.ppk"

Now that we have this setup we can connect to the machine. You can connect to the remote machine by clicking on the “><” symbol in the bottom left of VS Code or new icon that was added on the left bar of Visual Studio. If you want to customize your SSH configuration for the Remote-SSH extension a bit more you can find more at the links below.

Visual Studio Code Server

Another great option to working remote on projects is to use a code server. This allows me to run VS Code in a docker container or directly on a VM. I personally use one dockerized VS Code Server for editing my home lab files such as Homer config, Jekyll Blogs, Pi-Hole DNS List, and even my Cloudflared configuration. In a separate VS Code instance running I installed it directly on a Ubuntu 20.04 VM on my Synology NAS. In this VS Code instance I can work on malware development using gcc and mingw to compile Linux and Windows payloads. The reason I would use this over VS code on the desktop is when I need to work on a project or make some changes I can edit the files from anywhere with or without my computer.

Another cool thing is that I can essentially use any computer that has access to a web browser to edit my projects. So I could use my phone, an iPad, library computer, Raspberry Pi, or a friends computer to edit my projects without the need of having to carry around my laptop.

Below is a screen shot of my VM VS Code instance with access directly to the Linux terminal:

Below is a screen shot of my Dockerized instance of VS Code:

This post is licensed under CC BY 4.0 by the author.