4

Visual Studio Remote - SSH Extension: Overview & How-To

 1 year ago
source link: https://keyholesoftware.com/2022/12/04/remote-development-with-visual-studio-code-remote-ssh/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SSH Extension: Overview & How-To

Visual Studio Code Remote - SSH extension

Does your personal laptop struggle to keep up with your development needs? Maybe your company is looking for alternatives to continually needing to upgrade their developers’ laptops. Maybe a team of developers would benefit from a powerful remote server versus personal computers?

Today, remote development is even more streamlined than ever with the help of products like Visual Studio’s Remote – SSH extension or with Jetbrains Remote Development. In this blog post, I will give a brief overview of Visual Studio’s Remote – SSH extension and share a mini how-to on using it.

Visual Studio Code Remote – SSH Overview

The Visual Studio Code Remote – SSH extension allows you to open a remote folder via SSH while still being able to code locally like normal. As long as an SSH server is running remotely on your remote machine, you can use a remote machine, a virtual machine in the cloud, or a remote container.

The source code and heavy lifting are 100% remotely executed. While this extension may not fit all use cases, I would strongly encourage anyone to try it out. It’s helpful and relatively easy to use! However, as with any product, there can be some pain points. For example, opening a remote container within Visual Studio over SSH is possible, but it may take some trial and error to get it working properly.

Overall, I have had a very positive experience with the Remote – SSH extension, and I think it can be of benefit to almost anyone. In conjunction with a home server, I use this extension whenever possible to remove the heavy lifting from my laptop battery and CPU.

Getting Started

Now that we’ve covered what the Visual Studio Code Remote – SSH extension does, let’s dive into how to get it set up on your machine. This section will be a mini tutorial on how to get started.

Requirements:

Before we dive in, here are some requirements. Make sure you have these installed before moving on to the next step.

Local:

  • Visual Studio Code
  • SSH Client

Remote:

  • SSH Server
  • Debian 8+
  • Ubuntu 16.04+
  • Windows 10+
  • MacOS 10.14

SSH Setup:

Without further ado, let’s dive into setting up Visual Studio Code Remote – SSH!

Local:

  1. Install an SSH client if needed.
  2. Install Visual Studio Code.
  3. Install Remote – SSH extension.

Remote:

  1. Install an SSH server if needed.
  2. I recommend setting up key-based authentication per user instead of using passwords.

Connect to Remote:

1. First, in a terminal, test that SSH to the remote server is working properly.

Hoffman-1-1.png

2. Next, navigate to the command palette in VS Code (Control + Shift + P). Select Remote-SSH: Connect to Host. Enter your remote server SSH host.

Visual Studio Code Remote - SSH

3. The bottom left corner of VS Code displays the current status. Here is what it looks like if you are connected.

Hoffman-3-1.png

4. Now, you can open any folder on the remote machine just like you would locally. File > Open Folder > Your Project Folder.

Hoffman-4.png

5. Within the VS Code terminal, run any commands just like it is a local project. Ports should be automatically forwarded. Here is the example project I used for these screenshots.

Hoffman-5.png
Hoffman-6.png

6. If needed, a port can be manually forwarded.

VS code remote - ssh

7. Everything is now up and running and all without any laptop fans spinning up.

Hoffman-8.png

Closing Thoughts

Hopefully, this brief overview generates enough interest and gives you enough information to check out this VS Code feature on your own. If you’re not a VS Code fan, there are other options out there with similar benefits that I would encourage you to look into!

Remote SSH development is not a one size fits all, but it is a powerful tool for both teams and individuals. Depending on your requirements, I think it can benefit almost any project.

Thank you for taking the time to read this post! If you have comments, or if you use a different tool for remote SSH development, drop a comment below. And if you enjoyed this post, check out the many others on the Keyhole Dev Blog.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK