How to Download Key Pair Again Aws

Wondering What A "Key Pair" Is?

When yous want to launch an EC2 instance in AWS, yous need a central pair. A Key Pair AWS helps usa to access our instances without using a password. Key pairs ameliorate the security by preventing the password from existence kept in a file and prevents password stealing from your compromised estimator. This key pair consists of a private primal (a file with the extension of .pem/.ppk) and a public key (using a private and a public key is the asymmetric encryption method).

You can use a private key to access your instances securely. You shop the private fundamental in your local calculator and EC2 instances store the public central. EC2 instances get the public central contents from the metadata of the instance and shop it in a file named "authorized_keys" nether "/home/ec2-user/.ssh" directory.

When connecting to an case, you must specify the name of the private cardinal and its directory. This control is used for connecting to a linux instance via ssh:

(ssh -i "mk.pem" ec2-user@ec2-3-84-226-57.compute-1.amazonaws.com)

The name of the private primal (mk.pem) is specified in the control and nosotros take the individual cardinal in the current directory.

Resim1

If your current directory is different from the directory of the private key, you can utilise an absolute and relative path to define the directory of the private key.

Resim2

Wondering How To Create Primal Pairs?

We'll prove you three ways of creating fundamental pairs. Ane method is to run the "ssh-keygen" command and the other ways will be ready from the AWS Panel.

ssh-keygen is a command/tool (OpenSSH format) for generating authentication primal pairs for SSH.

SSH supports other public central algorithms (rsa, dsa, ecdsa, ed25519) for cardinal pairs (in this article we will employ rsa.) You can utilize the "ssh-keygen -yard PEM" command for generating a new set of primal pairs. Past default, the command creates a private fundamental whose name is "id_rsa" and a public cardinal whose name is "id_rsa.pub" (NOTE – you lot can alter the proper name of key pairs). After you lot run the command, it asks where to relieve the file. All-time practice – store central pairs in the .ssh directory under the user's home directory locally. After that, you need to import your Public key contents from your local reckoner to AWS. And then you tin easily admission your EC2 instance with created key pairs.

Method #1

The starting time way y'all can create a fundamental pair from the AWS panel is to create a central pair when yous are launching your EC2 instances. The motion-picture show shows the last step (Step 7: Review Instance Launch) of launching an case. You can create your central pair with "Select an existing key pair or create a new key pair" pop-upward window. First choose the "Create a new primal pair" then write the name of the key pair and click the "Download Key Pair" . You need to download the file because you will not exist able to download it again afterwards it is created.

Resim3

Method #2

The second style you tin can create a fundamental pair is to use the EC2 console. Open the EC2 console. In the navigation pane, nether the NETWORK & SECURITY, click "Key Pairs". Then, in the upper right corner of the page click "Create Fundamental Pair."

Resim4

Write the name of the cardinal pair and choose file format. Pem file format is used with OpenSSH and ppk file format is used with PuTTY. Now you tin click "Create central pair" push button.

Resim5

Method #3

There is another way to get the contents of the public key…

First, launch an EC2 instance with the private key that you want to import to another region and connect that instance via ssh. Under the domicile directory of ec2-user, there is a hidden ".ssh" directory. Under the ".ssh" in that location is a file whose name is "authorized_keys" that stores contents of the public key. You can too meet your public primal contents in the metadata of the example with this command "TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600″` && curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key".

Resim6

In our example, we take successfully imported our key pair from N.Virginia region to Ohio region. We can apply the same key in both regions (Due north.Virginia and Ohio)

Resim7

Here's How to Import The Key Pair To Another Region

Y'all may want to move the key pair to other regions for a number of reasons. You lot can import primal pairs to some other region in the EC2 console.

Instance: Nosotros created our key pair (mk-second) in N.Virginia and we want to import it to the Ohio region. Open the EC2 console – in the navigation pane under the NETWORK & SECURITY click "Key Pairs" for both of the regions. Nosotros will import a mk-second key pair (in N.Virginia) to the Ohio region. (Nosotros practise not have any key pairs in the Ohio region.)

Resim8

Switch to the Ohio region and open the EC2 console and in the navigation pane under the NETWORK & SECURITY click "Key Pairs". In the upper right corner of the page, click "Actions" button and choose "import key pair".

Resim9

Write the same name of the fundamental pair created in Due north.Virginia region. Afterward that, if you have your public key file y'all tin can select it with the "Browse" push button or paste the contents of the public primal into the text box. You can generate your public key with this command "ssh-keygen -y -f mk-second.pem > $Abode/.ssh/mk-2nd.txt" in the directory of your individual central file.

Resim10

This command volition salvage your public key every bit an mk-2nd.txt file. You lot can browse and select mk-2d.txt file or copy and paste the content of mk-2d.txt file into text box. Then, click "Import key pair" push button.

Resim11

hymanwhisconce71.blogspot.com

Source: https://clarusway.com/how-to-create-a-key-pair-and-import-to-another-region-in-aws/

0 Response to "How to Download Key Pair Again Aws"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel