How to Create an Ubuntu 20.04 Server on AWS Lightsail
Table of Contents
Lightsail is a virtual private server (VPS) service from Amazon Web Services (AWS). It allows you to rent by the hour computers (called servers) running in one of AWS's many data centers across the globe. You can use your VPS by connecting to it over the Internet.
A VPS is "virtual" because the server you're renting is one of many running on a single physical hardware computer. Although you're not using an entire physical hardware computer by yourself, the VPS still acts like a whole standalone machine, and you have full control over it (hence the word "private").
A single server running in Lightsail is called an instance. Thus when we launch a new server in Lightsail, we say we are "creating a new instance."
This tutorial describes how to create a new instance in Lightsail running the Ubuntu 20.04 Linux-based operating system.
Step 1. Open AWS Cloud Shell
Open AWS Cloud Shell. The rest of the instructions on this page are for running inside Cloud Shell.
Step 2. Set the AWS Region
aws command which AWS geographic region you want to use by setting the
AWS_REGION environment variable. For example, if you want to use the
us-west-2 (Oregon) region, you should run:
You can find out more about available regions here.
Your new instance will be created in this region.
At the Cloud Shell prompt, choose a name for your new instance and export it as an environment variable. For example, if you chose the name "myubuntu" you would run:
We will use this environment variable in the commands below.
Now create a new instance using that name:
Since we did not specify a key pair in the
create-instances command above, Lightsail automatically used the default key pair for your account for the new instance.
Let's download the default key pair and save it to your Cloud Shell:
$ $ $ $
Now let's create a new SSH config file for your new instance.
$ $ $
Finally, add a reference to the new config file in your main
~/.ssh/config file so the
ssh program knows to load it.
Now you can use the instance name you chose above to open an SSH connection to your new instance. If you chose "myubuntu" as the name, you can run:
If this command fails immediately after you create your new instance, try waiting a minute or two for the server to finish booting before retyring the command.
When you connect, you should see a message like:
At the prompt, type
yes and press Enter on your keyboard to continue. You will only have to do this once — the next time you open an SSH connection, this message will not appear.
You now have a shiny new Ubuntu 20.04 server running in AWS Lightsail. Enjoy!