Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Setup Remote Development in VSCode via Remote-SSH Plugin - DesignLinux

Mar 04 2021
designlinux 0 Comments

In this article, we will see how to set up remote development in visual studio code via the remote-ssh plugin. For developers, it is indeed an important task to choose proper IDE/IDLE editors with batteries included.

Vscode is one of such tools that comes with a nice set of packages that makes our life easy and improves the productivity of the developers. If you have not yet configured vscode take a look at our VScode installation article on setting up vscode in Linux.

For testing purposes, my Visual Studio Code is running on Linux Mint 20 and I am trying to connect with CentOS 7 running on my VirtualBox.

Install Remote-SSH in VSCode Editor

Go to the package manager and search for the “Remote SSH” package, which is owned by Microsoft. Click the Install icon to install the package.

Install Remote SSH in VSCode
Install Remote SSH in VSCode

An additional package, “Remote-SSH Edit config” will be automatically installed along with this package.

Remote SSH Edit Config
Remote SSH Edit Config

Look at the bottom to the left where you will have a remote-status bar. Using this bar you can open frequently used remote ssh options.

Configure SSH Connection in VSCode Editor

There are two ways we can configure our SSH connectivity.

  • Password-based authentication.
  • SSH key-based authentication.

It is recommended to use SSH key-based authentication as it is more secure and removes the overhead of typing passwords all the time. Press F1 or CTRL+SHIFT+P and type remote-ssh. It will show a list of all options. Go ahead and select Add New SSH Host.

Add SSH Host in VSCode
Add SSH Host in VSCode

Now it will prompt you to enter the SSH connection string as you do it in the Linux terminal.

ssh [email protected]/fqdn
SSH Connection in VSCode
SSH Connection in VSCode

In the next step, you will be prompted with the configuration file location where you want to store connection information. select the location which suits you and press enter.

SSH Configuration File
SSH Configuration File

It is recommended to create a custom configuration file by choosing “settings” and enter the custom file location. You can also add the “remote.SSH.configFile” parameter to the settings.json file and update the custom configuration location.

{
    "remote.SSH.configFile": "path-to-file"
}

Below are the parameters stored in the config file as part of the previous steps. You can go ahead and configure this file straight away instead of doing it through vscode.

Host xxx.com
    User USERNAME
    HostName FQDN/IP
    IdentityFile "SSH KEY LOCATION"

Connect to Remote SSH Server via Password in VSCode

Now let’s connect to the remote host by hitting F1 or CTRL + SHIFT + P –> REMOTE-SSH –> CONNECT TO HOST –> CHOOSE HOST IP.

It will now prompt you to verify fingerprint since this is the first time connecting with a remote machine.

Verify SSH Fingerprint
Verify SSH Fingerprint

Once you press “Continue” it will now ask you to enter a password. Once you enter the password it will successfully connect to the remote SSH machine.

Enter SSH Password
Enter SSH Password

Now vscode is connected to a remote machine.

VSCode SSH Connection
VSCode SSH Connection

Set Up SSH Key Based Authentication on VSCode

To enable SSH key-based authentication, generate ssh public and private key pairs using the below command.

ssh-keygen -t rsa -b 4096
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

Now login to the host manually to see if key-based authentication works fine. Open your VScode remote SSH configuration file and add the below parameter. This parameter identifies your private key file and tells vscode to use key-based authentication instead of password-based authentication.

IdentityFile ~/ssh/id_rsa

Vscode supports autosuggestion for the configuration files. Check the below image, when I type am typing “IdentifyFile” vscode automatically suggests me the parameter.

VSCode Auto Suggestions
VSCode Auto Suggestions

Once again connect with your host by following the same procedure as we did in previous steps. This time you will not be prompted for a password. If you have any problem in establishing a remote connection you can check the logs.

To open logs, Press F1 or CTRL + SHIFT + P –> REMOTE-SSH –> Show Log.

VSCode Logs
VSCode Logs

To close the active connection choose “close remote connection” by hittings F1 or CTRL + SHIFT + P –> REMOTE-SSH –> Close Remote Connection or simply close vscode which will disconnect the session.

Close SSH Connection in VSCode
Close SSH Connection in VSCode

That’s it for this article. If there is any valuable feedback kindly share it in the comment section. Your feedback is what is driving us on a path to deliver better content to our readers.

Related

Tags: VSCode Tips

How to Install Terraform in Linux Distributions

Prev Post

How to Install CHEF Workstation in RHEL and CentOS 8/7

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 772
  • 597,577

DesignLinux.com © All rights reserved

Go to mobile version