d. Create a Key Pair

In this section, you create an SSH key-pair on your AWS Cloud9 instance, which you can use for EC2 instance and Parallel Cluster creation.

Generate an SSH Key-pair

SSH is commonly used to connect to Amazon EC2 instances. To allow you to connect to your instances, you can generate a key-pair using the AWS CLI in your AWS Cloud9 instance. This example uses the key name lab-your-key but you can change the name of your key. Enter the following command to generate a key pair:

aws ec2 create-key-pair --key-name lab-your-key --query KeyMaterial --output text > lab-your-key.pem
chmod 600 lab-your-key.pem

Next add it to the ~/.bashrc file, this allows us to reference it later:

echo "export AWS_KEYPAIR=lab-your-key" >> ~/.bashrc
source ~/.bashrc

Optionally, use the following command to check if your key is registered:

aws ec2 describe-key-pairs