In this article, we will see how to create key pairs using AWS Management Console but before that let's try to understand why we need to create key pairs. If you are creating an AWS EC2 instance then you will get an option to either create a new key pair or specify an existing one to connect to the instance through SSH protocol. This key pair is basically a combination of public and private key where public key will be generated and stored in your EC2 instance and private key will get downloaded and stored locally in your system so that whenever you needed to connect the instance you can use that private key.
Not just you but anyone who needed to securely connect to that instance has to use that private key that corresponds to the public key stored in the
~/.ssh/authorized_keys path then only connection to the instance will be successful. Any attempt to use some other private key for authentication will result in unsuccessful connection. Hence before creating an EC2 instance, it is mandatory to create a key pair in case you don't have it. You can follow below simple steps to create a key pair.
How to Create Key Pairs Using AWS Management Console
Step 1: Prerequisites
a) You should have a valid
b) You should have sufficient
IAM access to create resources in your account.
Step 2: Login to AWS Management Console
Open AWS Management Console Login In page by visiting URL https://aws.amazon.com/console/ in your favorite browser and sign in with your valid AWS Credentials.
Step 3: Go to EC2 Dashboard
Once logged in, you will need to open
EC2 Dashboard by searching
EC2 service in the search box as shown below. Once it shows up, tap on it to open.
Step 4: Open Key Pairs
EC2 Dashboard, you need to scroll down to
Network & Security and click on
Key Pairs option as highlighted below.
Step 5: Create a Key Pair
You will see key pairs section will open where you need to click on
Create key pair to create a public and private key.
Under Create key pair, you need to provide the key pair name, select the key pair type and finally select the private key file format. In our case, we are selecting Key pair type as
RSA and Private key file format as
.ppk as shown below. You can also select any other available key format depending on your requirement. Once done, click on
.ppkfile if you need to connect EC2 instance from a Windows based OS. But if you are planning to connect the instance from any Linux/Unix based machines then you need to save the private key as
It should successfully create the key pair as shown below.
And now you should be able to download the Private key in your local machine as shown below.