cover image
IoT

Working Remotely Using Visual Studio Code

In many circumstances it is convenient to work remotely using Visual Studio Code. There is a fine VS Code extension that allows you to work on a remote machine as if it was your local machine. This is great for things like embedded programming or developing in the cloud. Read here how to do this.

Why Working Remotely

Often when working on embedded projects like IoT devices you have two possibilities. One is to use a development machine that is separated from the embedded device and work there. Depending on the programming language, you will possibly need to use a cross-compiler to generate the version suitable for the embedded device. The other possibility is to directly work on the embedded device and develop there. This has the advantage of finding errors earlier, but may not always be possible due to device constraints.

But now with the "Remote SSH" extension for Visual Studio Code you can comfortably develop within Visual Studio Code on your development machine and execute directly on the embedded device. This makes development on remote machines more convenient. The source code and the execution environment are directly located on the remote machine. You can access the remote machine comfortably via your development machine.

The next step is how to install the extension.

Installing the Remote - SSH Extension

The pre-requisite for using the Remote SSH Extension is that the remote (e.g. embedded) machine has a running SSH server and a minimum of 1GB of RAM. This includes most versions of the Raspberry Pi as well as many server instances of cloud providers.

In Visual Studio Code you can install the Remote SSH Extension via the extension tab like so:

Screenshot Remote SSH Extension

Connect to Remote Machine

Once you have installed the extension, you can connect to your remote device via the command palette and search for "Remote-SSH: Connect to Host...". Now enter the IP address and then the user name and password of you remote machine.

Connect to remote machine

Upon a successful connect, you wil see a new Visual Studio Code window where you can directly edit source files and execute scripts in the terminal. The great thing is that you can open source files that are located directly on your remote machine but edit them seamlessly on your development machine. In case you need other language specific VS Code extensions like for example for editing Python you can install them there.

Once you have developed your first project with the help of the extension, you will notice that it is faster and esier than installing everything from scratch on the remote machine. Often it is even not possible to work with Visual Studio Code directly on the remote or embedded device.

Conclusion

I hope in this article you could learn something new about the useful Visual Studio Code extension "Remote SSH". I am sure you can find other use cases like working remotely on cloud machines. If you like the extension do not hesitate to write me, I would love to hear from you.

References

Cover photo: Chung Yee Tsang on Unsplash

Published 8 Dec 2023
Thomas Derflinger

Written by Thomas Derflinger

I am a visionary entrepreneur and software developer. In this blog I mainly write about web programming and related topics like IoT.