docker

Part 4: How to connect a Virtual Machine to Visual Studio Code

Anebula is reader-supported. When you buy through links on our site, we may earn an affiliate commission.

This guide is part of the How to host multiple sites on one virtual machine with Docker series where you learn how to create a virtual machine (VM) to host multiple websites and apps. In this series, we will host a WordPress blog, a Ghost blog, a Matamo Analytics app, and much more!

Up to this point, we have purchased a domain and set up the domain with Cloudflare DNS, then we created a VM on Digital Ocean. Now it is time to connect to that VM.

Now when it comes to SSH clients to connect to a VM you will have lots of options. One of the most ubiquitous solutions is Putty. However, I find Putty to be outdated and lacking the modern features that you get with Visual Studio Code. For that reason, I do all my SSHing with VSC now.

Part 1: Download Visual Studio Code (VSC)

Head over to https://code.visualstudio.com/, download, and install VSC on your computer.

Part 2: Install Remote SSH Extension

Open VSC, then under extensions search for “ssh” and install Remote – SSH by Microsoft extension.

Part 3: Set up Remote SSH extension

In VSC, click on the new Remote Explorer extension, then under SSH click on the gear icon, then click on the first item that shows your username\.ssh\config.

A config file will open up. This is how we will fill it out.

Host droplet
    HostName <the IP of your new VM>
    User <the username of your new vm>
    IdentityFile <path to your openSSH private key file>
This is exactly what my config looks like…minus the hidden IP octets.
PropertyDefinitionExample
HostThe name of the connection, you can make up any name here as long as there are no spaces in the name.droplet
HostNameThe IPv4 of the VM. You can get this from the Droplet page in Digital Ocean.54.20.240.56
UserThe user who the SSH get is associated with. For Ubuntu on Digital Ocean VMs, this is always “root” by default. root
IdentityFilePath to your openSSH exported key from PuttyGen“C:\Users\vmw11\Desktop\SSH Private Keys\dropletopenssh”

Then save the config and click the refresh button.

Then a new line will appear showing the new connection and we can connect to it.

The windows will reload and you can select the following options.

Platform: Linux

Are you sure you want to continue? Continue

Then go ahead and enter the passphrase that you created in PuttyGen (you created this passphrase in the previous post)

At this point, you should be connected. You can verify this by looking at the bottom left corner of VSC. You should see “SSH: droplet”.

Now you can click on Explorer > Open Folder.

Then leave it to the default “/root/ “to open the root directory and click OK.

Enter your passphrase again, the window will reload, then you can trust the author since this is your private VM.

From this point on, you are in the VM and can control it just like you can control your own computer.

This is not covered in this guide, but I highly recommend setting up unattended upgrades to capture security upgrades as they are released. There is a guide for that here.

At this point, we are done setting up the machine and we can move on to setting up Docker via Docker Compose.

Continue with Part 5: How to set up NGINX Proxy Manager using Docker Compose

Michael

Recent Posts

Docker Compose Stack for Home Assistant with Grafana and InfluxDB

Documentation on this from a Docker Compose angle is sparse, so I wanted to share…

1 week ago

Ceiling Fan Smart Wall Switch With Fan Speed and Dimming Control

My house gets hot in the summer, and while central air helps, it's not enough.…

2 months ago

Must-Have Open Source Ubuntu 24.04 & Debian 12 Applications

Nextcloud Desktop Client Usage: Sync files to Nextcloud Server The Nextcloud Desktop Client syncs to…

7 months ago

TP-Link Omada and pfSense Setup for 2023 (Updated for July 2024)

It's been two years and firve months since I upgraded to TP-LInk Omada and pfSense.…

1 year ago

Part 6: How to set up multiple WordPress sites on Docker

This guide is part of the How to host multiple sites on one virtual machine…

2 years ago

Part 5: How to set up NGINX Proxy Manager using Docker Compose

This guide is part of the How to host multiple sites on one virtual machine…

2 years ago