3.1.3. Using Linux Instance
This lab shows how to create an Linux EC2 Instance using AWS Management Console.
To complete this lab, perform the following tasks:
- Launch a Linux Instance
- Connect to Linux Instance
- Clean Up Linux Instance
Step 1: Launch an instance
In this lab, we will launch a Linux instance using the AWS Management Console.
- We will go to the Amazon EC2 console at https://console.aws.amazon.com/ec2/
- To create an instance, click on Launch Instance.
- The Choose an Amazon Machine Image (AMI) page shows a list of Amazon Machine Images (AMIs), that serve as templates for your instance. Select an HVM version of Amazon Linux 2.
- On the Choose an Instance Type page, you can select the hardware configuration of your instance. Select the
- Select Review and Launch to let the wizard automatically config other settings as default.
- On the Review Instance Launch page, under Security Groups, you’ll see that the wizard created and selected a security group for you. You can use this security group, or alternatively you can select the security group that you created when getting set up using the following steps:
- Choose Edit security groups.
- On the Configure Security Group page, ensure that Select an existing security group is selected.
- Select your security group from the list of existing security groups, and then choose Review and Launch.
- On the Review Instance Launch page, choose Launch.
- When prompted for a key pair, select Choose an existing key pair, then select the key pair that you created when getting set up.
Alternatively, you can create a new key pair. Select Create a new key pair, enter a name for the key pair, and then choose Download Key Pair. This is the only chance for you to save the private key file, so be sure to download it. Save the private key file in a safe place. You’ll need to provide the name of your key pair when you launch an instance and the corresponding private key each time you connect to the instance.
Don't select the Proceed without a key pair option. If you launch your instance without a key pair, then you
can't connect to it.
- When you are ready, select the acknowledgement check box, and then choose Launch Instances.
- A confirmation page lets you know that your instance is launching. Choose View Instances to close the confirmation page and return to the console.
- On the Instances screen, you can view the status of the launch. It takes a short time for an instance to launch. When you launch an instance, its initial state is pending. After the instance starts, its state changes to running and it receives a public DNS name. (If the Public DNS (IPv4) column is hidden, choose Show/Hide Columns (the gear-shaped icon) in the top right corner of the page and then select Public DNS (IPv4).)
- It can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its status checks; you can view this information in the Status Checks column.
Step 2: Connect to your instance
There are several ways to connect to your Linux instance.
In this lab, we will try to connect to Linux instance by using PuTTY on Windows.
Connect to Linux instance by PuTTY on Windows
- Select the instance in Instance list then go to Actions > Connect
- Then in Connect to your instance dialog box, note the Public DNS information. (Here is
- Open PuTTYGen to convert the keypair download when creating the instance (in
.bib format) to
- In PuTTYGen, click Load to select the Key Pair downloaded. (If we can not see the file, please change the File type in Open dialog to
All File (*.*))
- Choose Save private key to save Key pair to
- Open PuTTY to connect to Linux instance:
- The Host Name should be
ec2-user@<Public DNS> (List of username can be found in General prerequisites for connecting to your instance)
- In PuTTY, navigate to Connection > SSH > Auth then select the converted private key.
- Finally, click Open to connect to instance
- If a dialog display about PuTTY Security Alert, click on Yes to accept the host key, put it to cache and continue to connect.
Step 3: Clean up Linux instance
It will be the same as terminate a Windows Instance. For more details step, you can return to Clean up Windows instance
To terminate your instance
- In the navigation pane, choose Instances. In the list of instances, select the instance.
- Choose Actions > Instance State > Terminate.
- Choose Yes, Terminate when prompted for confirmation.
Amazon EC2 shuts down and terminates your instance. After your instance is terminated, it remains visible on the console for a short while, and then the entry is deleted.