Install Visual Studio Code
Visual Studio Code
We will use Microsoft Visual Studio Code on our host system to edit our code and interact with our Ubuntu system via SSH. You can run Visual Studio Code on any OS flavor you want.
Install
Download Visual Studio Code - Mac, Linux, Windows
You can download the install from above, but you may use a package manager. The following examples allow for single command installation.
macOS
brew install visual-studio-code
Windows
choco install vscode
Start Power Shell and check if the OpenSSH client is installed by running the following command. OpenSSH Client should be installed unless you have an older Windows version.
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Loading image...
If it is not installed, run the following command in PowerShell to install it.
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Linux
sudo snap install --classic code
Setup (Local)
-
Open up VS Code, and in the top right, click Open Folder.
Loading image...
VS Code Open Folder
-
Find the folder you would like to work with. You can use your user folder or the project folder.
Setup (Over SSH)
-
Click the extension icon on the left side.
Loading image...
-
Search for the Remote Development extension and click install
Loading image...
-
You should now see a remote icon in the bottom left. Click the icon in the bottom left to connect to a remote host.
Loading image...
-
Click Open SSH Configuration to change your user SSH configuration.
Loading image...
-
Select your SSH config file. I usually use the one for my user.
Loading image...
-
Confirm the IP address for the host you want to connect to. In the case of our VM, you can run the
ip address
command in the console to get the internal IP address.Loading image...
-
Add the following lines to the ssh config file with the internal IP address. Then save this file.
Host ubuntu HostName 172.19.2.227 User vagrant
-
Click the bottom left green icon, but this time select connect to host.
Loading image...
Loading image...
-
From the list, select the hostname. In our case, it is ubuntu. It will be whatever you named the host in the ssh config file.
-
Click “Continue” when asked about the SSH key fingerprint from the server. This will only happen the first time you connect to the VM.
-
Since we are not using an SSH key, we are prompted for an SSH password. The password will be
vagrant
for the provided VM.Loading image...
-
Now that we are connected use the folder icon in the top left and select Open Folder.
Loading image...
-
Select your home folder and press OK.
Loading image...
You’re now connected to your remote host over SSH. You can now open a terminal and interact with the remote files inside VS Code. Put down your Nano/Vim.
Loading image...
Setup Plugins
Let’s add a few plugins that will be useful for this training.
-
Click the Extensions icon in the left-hand bar.
Loading image...
-
Search the marketplace for Terraform, then click the install button next to the extension just named
Terraform
. It should be at the top.Loading image...
-
Finally, search for Ansible and install this plugin as well.
Loading image...
There are other plugins that are useful, but for now, that’s all we will need. These plugins will help with syntax highlighting and formatting.