This article details the process of deploying and configuring your own Remote Development Server with Linode and Ubuntu. This article will also explain the best practices when setting up an Ubuntu server and how to create an SSH Key.
In order to follow along with this guide, you'll need:
- A local development machine running Windows, Mac OS X or Linux.
- Visual Studio Code, which can be downloaded and installed from the official website.
- A Linode Account.
Step 1 - Deploying a Linode Instance
To get started, we first need to deploy our Linode Server. To ensure that we have plenty of headroom to run our applications, we will be deploying a Shared 4GB Linode Instance with Ubuntu as our distribution of choice.
Simply select the latest Ubuntu Distribution from the drop down menu, select a region and the select the Linode 4GB Plan.
Next, we need to give our Linode Instance a name and password. Once this has been filled out, we are ready to create our Linode Instance!
Please note: We recommend that you pay for automated backups of your Linode Instance in the case that you need to rollback any changes to your server.
It can take anywhere from 5-10 minutes for the server to deploy.
Step 2 - Logging into your Linode Instance
Once your server has deployed successfully, we need to remotely log in to the server using the SSH protocol. To do this, open a Windows Command Prompt and type the following:
You can find your servers IP address on Linode's Overview page as demonstrated below:
Step 3 - Updating Ubuntu and Creating a User
Once we have successfully logged in, we need to ensure that our Ubuntu Server is updated with the latest packages. To ensure our server is up to date, run the following command:
sudo apt update && sudo apt upgrade -y
Once our server is up to date, it is time to create a new user:
It's strongly recommended to create a new user as running your server from the root user makes the server more vulnerable to security breaches. Creating a new user allows us to lock down the server and improve its security.
You will be asked to create an account password and fill out some additional information. The additional information is not required and you may leave the fields blank if you wish.
Please see our article for tips on securing an Ubuntu Server.
Step 4 - Granting Superuser Privileges
We have successfully configured a new user. However, this new user does not have any superuser privileges. To avoid having to log out and log in every time we need to run a command with higher elevation, we can grant superuser privileges to our new user.
To add these privileges, run the following command as the root user:
usermod -aG sudo example
Now, the new user can run commands with superuser privileges by typing
sudo before commands.
Step 5 - Creating an SSH Key
Setting up an SSH Key with your server will make your life easier by not having to enter a username and password every single time you connect to the server.
Open a Command Prompt Terminal and type the following command to create a key pair on your local computer.
After executing the command, you should receive the following output:
Generating public/private rsa key pair. Enter file in which to save the key (/your_home/.ssh/id_rsa):
Press enter to save the key pair into the .ssh/ subdirectory. If you are asked to overwrite an existing key pair you may want to press ctrl+c and cancel if you had previously generated an SSH key pair.
You will then be prompted to enter a passphrase. This is an optionally step and requires additional configuration to setup with Visual Studio Code. If you are happy to proceed without a passphrase, simply hit enter. The SSH key pair has now been successfully generated.
Run the following command to copy your key pair to your Linode Instance:
cat ~/.ssh/id_rsa.pub | ssh example@your-server-ip "cat >> ~/.ssh/authorized_keys"
Replace example with your user and the IP for your Linode Instance. You have now successfully copied your SSH key pair to your server!
Step 6 - Configure SSH Key with Visual Studio Code
This step covers the process of adding the SSH Key Configuration File to Visual Studio Code. You’ll need the following pieces of information:
- The server’s IP or hostname.
- The username you’ll connect with.
- The private key that we generated above.
On the left-hand side of the IDE there is a vertical row of five icons. Select the bottom icon as shown below:
Search for the Extension Remote Explorer and install the extension.
Once the extension has been installed, select it on the left hand sidebar and select the Plus Icon as shown below:
Enter your SSH details for the Ubuntu Server.
You may be prompted to choose the hosts operating system. Select Linux.
Then go back to the extension and select the configure icon as shown below:
Select the following result:
Add the following lines to the config file:
PreferredAuthentications publickey IdentityFile %d\.ssh\id_rsa
The config file should now look like the following:
Host my_remote_server HostName your_server_ip User example PreferredAuthentications publickey IdentityFile %d\.ssh\id_rsa
Here’s how this configuration file works:
Host: This is where you can specify a nickname for your host. You can use this nickname instead of the full IP address or host name when connecting to the server.
HostName: The actual hostname of the server, which is either an IP address or a fully qualified domain name.
User: The user you want to use to connect to the server with.
IdentityFile: The path to your SSH private key. On Mac and Linux systems, you’ll find this in your home directory in a hidden
.sshdirectory, typically called
Make sure your
IdentityFile is linked to the
id_rsa private key that was locally generated on your machine.
Save the config file and connect to SSH Target by selecting as demonstrated:
You have successfully connected your Visual Studio Code to your Linode Instance.