Howto::VScode

From Computer Science Wiki
Revision as of 16:12, 31 March 2022 by Carnold (talk | contribs)
Jump to navigation Jump to search

Introduction

Visual Studio Code (vscode) is an increasing popular way of developing software on rlogin.cs.vt.edu. With the appropriate plugin, it will allow you directly edit your files on rlogin.cs.vt.edu and make it easy to get a terminal to run and test your code. These instructions are geared toward the Windows version of vscode, but should be easily adaptable to other operation systems. These instruction also assume that you already have the latest version of vscode installed locally.

Plugin installation and configuration

  • Make sure you also have an SSH client: https://code.visualstudio.com/docs/remote/troubleshooting#_installing-a-supported-ssh-client
  • Click on the "Gear" icon and select "Extensions" OR push <ctr>-<shift>-x
  • Search for "Remote - SSH"
  • Click the "Install" button
  • This should give you a small green button (bottom left) with "><" icon
  • Click on the green button and select "Connect to host..."
  • Select "+ Add New SSH Host..."
  • Type in "<username>@rlogin.cs.vt.edu -A" change <username> to your CS username
  • It should give you a dialog saying the host was added and a button to "Connect"
  • When you first connect it will ask you what platform the host is, select "Linux"
  • It will also likely ask for your password unless you already have a SSH key set up
  • Once connected, the green button should update with "SSH: rlogin.cs.vt.edu" letting you know you are connected remotely

Set up SSH key authentication

  • Setting up a public/private key will save you from having to enter your password so many times while using vscode
  • While inside VS Code, hit <ctrl>-o to open a file, open the local file: "c:\Users\<username>\.ssh\id_rsa.pub" If this file does not exist, then you can run "ssh-keygen" from the command to generate the file
  • Copy the whole contents of this file
  • Use VS code to edit the remote file: ~/.ssh/authorized_keys (if this is your first time, then you might have to create it as a new text file)
    • Alternately, you use the command line to SSH into rlogin.cs.vt.edu and edit the file directly using the command `nano ~/.ssh/authorized_keys`