How To Install ec2-instance-connect on Ubuntu 18.04

In this tutorial we learn how to install ec2-instance-connect on Ubuntu 18.04. ec2-instance-connect is Configures ssh daemon to accept EC2 Instance Connect ssh keys

Introduction

In this tutorial we learn how to install ec2-instance-connect on Ubuntu 18.04.

What is ec2-instance-connect

ec2-instance-connect is:

EC2 Instance Connect is a service that publishes ssh keys for use by EC2 instances based on AWS Credentials. These keys are consumed by on-instance configuration provided by this package. The ssh daemon will query EC2 Instance Metadata service for user-keys at ssh calltime, validate any if present as well as validating their signature, and if all checks pass return will include them in the authorized keys list.

In addition, there is an agent that harvests instance ssh host keys and passes them back to the service. This is for authentication purposes by the EC2 console to open an in-browser ssh terminal connection.

There are three methods to install ec2-instance-connect on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install ec2-instance-connect Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install ec2-instance-connect using apt-get by running the following command:

sudo apt-get -y install ec2-instance-connect

Install ec2-instance-connect Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install ec2-instance-connect using apt by running the following command:

sudo apt -y install ec2-instance-connect

Install ec2-instance-connect Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install ec2-instance-connect using aptitude by running the following command:

sudo aptitude -y install ec2-instance-connect

How To Uninstall ec2-instance-connect on Ubuntu 18.04

To uninstall only the ec2-instance-connect package we can use the following command:

sudo apt-get remove ec2-instance-connect

Uninstall ec2-instance-connect And Its Dependencies

To uninstall ec2-instance-connect and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove ec2-instance-connect

Remove ec2-instance-connect Configurations and Data

To remove ec2-instance-connect configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge ec2-instance-connect

Remove ec2-instance-connect configuration, data, and all of its dependencies

We can use the following command to remove ec2-instance-connect configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge ec2-instance-connect

References

Summary

In this tutorial we learn how to install ec2-instance-connect package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.