jlelse's Blog

Thoughts, stories and ideas

My new coding workflow: VS Code + Remote-SSH extension

Published on in 👨‍💻 Dev
Share 

I recently rediscovered the ability of Visual Studio Code to develop on remote machines. Just connect to a server via SSH and develop there.

Even though I’m using Git, I don’t have to commit everything immediately to continue development on another machine, I don’t have to take care to keep all my development tools up to date on all my machines, and I can continue working from my Surface Go with Windows exactly where I left off with my Ubuntu desktop. And I can, for example, start drafting a blog post on one computer, but finish it on another.

All I need is a cheap rented virtual private server and Visual Studio Code on every machine I want to code from.


But first of all the reason why I got the idea in the first place:

To program in Go, I mainly used IDEA Ultimate from JetBrains in the past. The best IDE a developer can wish for. Excellent for Java, Kotlin, Go and a lot of other programming languages. And pretty cool: As a student you can get the full IDE for free.

However, since I won’t be a student forever and IDEA Ultimate or as an alternative just GoLand from JetBrains aren’t very cheap (at least for hobby projects), I thought I might get used to a different workflow now that will cost me less money later.

The second best option for developing Go is probably Visual Studio Code. The Go team took over the development of the Go extension not too long ago, which will hopefully make it more and more pleasant to develop Go programs with VS Code in the future.

VS Code is free, partly even open source and I already use it for quite a lot of things anyway, be it for writing longer blog articles or if I need to write some JavaScript. In itself it is just a text editor, but there are quite a few extensions that add all kinds of functionality. And VS Code is fast and available for all three major computer operating systems.

For VS Code there is an extension called “Remote - SSH” (documentation is available here) with which it is possible to connect to another computer or server via SSH. On the remote computer VS Code installs a remote server to provide almost all functionality that is possible locally. It’s like running VS Code directly on the remote computer and developing from there.

As a server I use the cheapest option from Hetzner Cloud. With just a few clicks I created a VPS with Ubuntu 20.04, two Gigabytes of RAM and 20 GB SSD storage. I also use Ubuntu 20.04 on my desktop computer and laptop, the environment I am used to. And if the server should be too weak for certain tasks, I can scale it up with a few clicks, even temporarily. The costs are 2,89 € per month. If I don’t need the server for a longer period of time, I could also create an image of the hard drive, delete the server and create a new one later based on the image. That would cost only a few cents per month.

This way I only have to install all the tools I need on the server. Like Go for the programming of various private projects or Hugo for this blog and my website. But I don’t have to install these tools on all my devices anymore, namely my desktop computer, my Ubuntu-ThinkPad and my Surface Go. There I only need Visual Studio Code with the “Remote - SSH” extension.

It definitely takes some getting used to in order to adapt to the less comfort you might be used to through the JetBrains IDE. But once you have found the right settings of the Go extension (for example that the Go language server gopls is used), then programming with this setup works quite well.

My favorite feature is definitely the ability to forward ports from the server to the local machine.

The only possible negative point is that I need an internet connection to develop so that I can connect to the server. But so often I am not without internet and even in Germany the mobile network should be sufficient for SSH. And when I am offline, I will just have to do something else.

Tags:

Jan-Lukas Else
Interactions
You can also create an anonymous comment.