Remote-access Guide

vscode remote access

by Dr. Emerson Lockman Published 2 years ago Updated 1 year ago
image

How to configure remote access in VS Code

Anyone that once developed for a remote system (such as Raspberry Pi or AWS) had to use a text editor to edit a piece of code in some moment. If you have used nano or vi you know what I’m talking about. Or have edited them on your computer and copied them over the internet just to find that you have a typo.

Passwordless SSH

To avoid having to keep insert the password every time you want to access the RPi, we can configure an SSH key to make this automatically. To check if you already have a key in your computer, run the command:

Configure VS Code

To enable the VS Code to access your remote system, you must install the plugin Remote-SSH. Go to Extensions area (Ctrl+Shift+X) and search for “Remote-SSH”.

Remote access

To access, just click on the file folder icon next to name you gave the connection. A new window will open. A message on the right bottom will show that the system is starting the connection.

Resume

You can now access your RPi or server using an IDE without having to copy and paste code into terminal or copying all the files via FTP.

In this article

For those of you that are familiar with the ISE, you may recall that you could run psedit file.ps1 from the integrated console to open files - local or remote - right in the ISE.

Local file editing with Open-EditorFile

With the PowerShell extension for VSCode started and the PowerShell Integrated Console opened, we can type Open-EditorFile foo.ps1 or psedit foo.ps1 to open the local foo.ps1 file right in the editor.

Remote file editing with Open-EditorFile

Now let's get into remote file editing and debugging. The steps are nearly the same, there's just one thing we need to do first - enter our PowerShell session to the remote server.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9