NetDevOps

Why Did No One Tell Me About This VSCode Remote - SSH Feature?

Why Did No One Tell Me About This VSCode Remote - SSH Feature?
In: NetDevOps, Network

I just discovered the VSCode Remote - SSH feature, and it's a game-changer (at least for me). This tool lets you code directly on a remote server (Linux VM for example) through SSH, right from your local VSCode. It brings your remote environment to your local workspace, making remote development much easier.

The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.

No source code needs to be on your local machine to gain these benefits since the extension runs commands and other extensions directly on the remote machine.

What Problem Does it Solve?

Let me share a challenge I faced until recently. My main machine runs Windows, but for my work with automation tools like Python, Ansible, Terraform, and others such as containerlabs and Git, I prefer a Mac or Linux command line environment. I didn't want to install these tools directly on Windows due to potential issues.

Initially, I thought about using WSL, but complications with Hyper-V and nested virtualization made that impractical. If I turned on WSL2, I wouldn't be able to use other VMs that require nested virtualization.

As a workaround, I set up Ubuntu Desktop as a VM on VMware Workstation. This meant frequently switching between my host machine and the VM, which wasn't ideal, but it was manageable.

Then, I discovered something today that changed everything. I can now work directly on my Linux machine using VSCode installed on my Windows host. All I needed to do was install the Remote - SSH extension in VSCode, SSH to my Ubuntu from local VSCode and that's it.

How to Use It?

Open VSCode in your host machine, install the extension called 'Remote - SSH' as shown in the following image.

Once you’ve installed the Remote - SSH extension, click on the blue icon in the bottom left corner of the VSCode window. From there, select 'Connect to Host...' to initiate a connection to your remote environment.

After that, when prompted, enter your ssh credentials with the syntax ssh admin@10.10.10.10 for example. Once entered, you will be prompted to enter the password and you are good to go.

It’s that easy to get started and integrate your VM's workflow into your local setup. You can open any files or folders from the remote machine and start working on them as how you would do it on the remote machine.

For example, I have some folders on the Ubuntu VM as shown below. I typically access the VM via the VMWare console.

Now, I can access the same files and folders via the VScode installed on my Windows machine.

I've got to say, discovering this feels like one of the coolest things I've come across in quite some time. Maybe it's common knowledge, and I've just been living under a rock, but either way, I'm glad I found it. I hope sharing this can help make your work a bit easier too. If it’s new to you, give it a try, it might just be the trick you didn’t know you needed.

Written by
Suresh Vina
Tech enthusiast sharing Networking, Cloud & Automation insights. Join me in a welcoming space to learn & grow with simplicity and practicality.
Comments
More from Packetswitch
Table of Contents
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Packetswitch.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.