You will now learn to create a new key pair that can be used for an instance. Not creating these key pairs can hinder your ability to connect to your EC2 instances, especially if those instances are not running Systems Manager Agent, as you will see later in this chapter in the Accessing an EC2 Instance Using Session Manager section.
There are two methods for creating key pairs:
Both methods are shown in detail in the sections below.
When you create a key during an EC2 instance creation, you will be able to create the new key pair in the Key pair (login) dialog box when configuring your new EC2 instance on the AWS Management Console (see the screenshot below).
Figure 11.1: Key pair screen for EC2 deployment
The following steps will show you how to create a new key pair using the AWS Management Console:
Figure 11.2: Key pair creation screen for EC2
Although creating a key pair when creating an EC2 instance seems convenient, you should also know how to plan out your key pairs beforehand. This is discussed next.
To create a new key pair from the EC2 dashboard, follow these steps:
Figure 11.3: Key pair in the EC2 console menu
Figure 11.4: Key pair screen for EC2
Figure 11.5: Key pair format selection
Your key pair will now appear in the list of active key pairs and can be used when you create new EC2 instances.
With the preceding steps, you learned how to create a key pair. But what if you ever need to delete it? The following section will deal with this.