Remote Development Using Digital Ocean: Remote SSH
A few years ago, I wrote an article about Using a DigitalOcean Droplet as a Development Environment, which focused on how to quickly create a droplet and connect using ssh, tmux & vim from my iPad Pro.
Let's update that for using devcontainers from a Macbook Pro and Visual Studio Code (vscode).
Following on from the example project from Devcontainers for Typescript
If you don't have a Digital Oceancommand-line account, start by creating one.
Remote SSH using VSCode
Then install the doctl
command-line tool.
Upload your public ssh key. You'll need the key id for the next step.
doctl compute ssh-key list
Now, create a droplet. We'll create a 4 virtual CPUs with 16 GB of RAM, so we have the power to run a full development environment. If you need less, then use a smaller server. We'll use the docker image so that docker is set up and available for us.
doctl compute droplet create vscode-ssh-test --size s-4vcpu-16gb-amd \
--image docker-20-04 --region nyc1 --ssh-keys xxxxxxx
When this is done, you can list them.
doctl compute droplet list
Create a firewall to only allow ssh
doctl compute firewall create \
--name "vscode-ssh-test-firewall" \
--inbound-rules "protocol:tcp,ports:22,address:0.0.0.0/0,address:::/0" \
--outbound-rules "protocol:icmp,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:all,address:0.0.0.0/0,address:::/0 protocol:udp,ports:all,address:0.0.0.0/0,address:::/0" \
--droplet-ids "YOUR_DROPLET_ID"
Note: you can future secure this by replacing the 0.0.0.0
with your IP address, which you can get with curl ipinfo.io/ip
Connect to it using the IP address and the root
user.
ssh root@xxx.xxx.xxx.xxx
Best to set up an alias in your ~/.ssh/config
Host digitalocean-example
Hostname xxx.xxx.xxx.xxx
User root
ForwardAgent yes
Now you can ssh in by name
ssh digitalocean-example
Clone your git repo, here I'll use https://github.com/markcallen/devcontainer-typescript-example
mkdir src
cd src
git clone https://github.com/markcallen/devcontainer-typescript-example
Now, ensure that you have the Remote SSH extension installed in your VSCode. For more details, see: Remote Development using SSH
From VSCode, open Remote SSH: Connect to Host and enter the name of the connection. For this example, I've used digitalocean-example
This will open a new VSCode window. Open, File: Open Folder and enter /root/src/devcontainer-typescript-example
When prompted, Reopen in Container.
You are now running in a devcontainer on a DigitalOcean droplet.

DigitalOcean charges for droplets even when they are off, so don't forget to delete them when done.
doctl compute droplet list
doctl compute droplet delete <droplet id>
Now you've set up a remote development environment using Visual Studio Code and devcontainers on a DigitalOcean droplet. The setup enables consistent, containerized dev environments accessible from anywhere, ideal for cloud-native workflows and team collaboration.