- Now let's talk about key pairs within Amazon EC2.
Key pairs here, how we're talking about these
are public and private keys.
So these types of key pairs means
that we have a private key
that we keep locally that we generally don't go giving out,
and then we have a public key
that is safe to give to other systems,
right, and so this enables public/private
key authentication and encryption.
And these are 2048-bit SSH-2 RSA keys.
Now, we can create these key pairs either directly
within AWS, so we could make a call
to the AWS API either with our CLI tools or in the console.
If we allow Amazon to create it,
we essentially download the private key pair from AWS.
Or we could create it locally
and import the public key half to AWS, right?
So either way, AWS will keep the public key
and AWS does not keep the private key.
Now, for those of us who might be overly security minded
and want to be as careful as possible,
then it might be a good practice for you
to create the keys locally and use the import method,
rather than having AWS create it.
By doing a local creation and import,
you know for a fact that AWS does not have that public key.
And then when we launch an EC2 instance,
we generally choose a key pair,
and by choosing a key pair,
that would allow us to gain remote access to
that instance later if we needed to.
Now, in the case of Linux,
the public key will be added
to the .ssh/authorized_key file,
and so that would allow us to authenticate into
that Linux operating system
using public/private key pair authentication.
We would use that private key
that exists locally in order
to authenticate into that Linux machine.
In the case of Windows,
the administrator password
is automatically encrypted by AWS,
and they use the public key to do the encryption,
we can then use the private key to do the decryption.
So keep that in mind that when if you need remote access
to an EC2 instance, we need a key pair.
Whether it's a Linux or Windows,
we need a key pair in order to enable
that remote access to our EC2 instances.