Before we create a Swarm cluster using Docker for AWS, we'll need to generate a Key Pair that we'll use to SSH into the EC2 instances.
To create a new key-pair
, please execute the command that follows:
aws ec2 create-key-pair \
--key-name devops21 \
| jq -r '.KeyMaterial' >devops21.pem
We executed aws ec2 create-key-pair
command and passed devops21
as the name. The output was filtered with jq
so that only the actual value is returned. Finally, we sent the output to the devops21.pem
file.
If someone gets a hold of your key file, your instances would be exposed. Therefore, we should move the key somewhere safe.
A common location for SSH keys on Linux/OSX systems is $HOME/.ssh
. If you are a Windows user, feel free to change the command that follows to any destination you think is appropriate:
mv devops21.pem $HOME/.ssh/devops21.pem
We should also change permissions by giving the current user only the read access and removing all permissions...