9/19/2020 Generate New Key Pair For Ec2 Instance
You can create a key pair using the console, AWS Command Line Interface (AWS CLI), or AWS Tools for Windows PowerShell. For more information, see Creating a Key Pair Using Amazon EC2. Note: To give the new key pair the same name as the lost key pair, you must first delete the lost key pair.
In AWS, when you launch any EC2 Linux instance, you should select a key pair for that particular instance.
AWS key pair will be in the standard private key format with .pem file extension
But if you are using PuTTY on your Windows laptop to login to AWS instance, you have a problem.
PuTTY doesn’t support PEM format. PuTTY understands only it’s own PPK format.
PPK stands for Putty Private Key.
So, you should convert your .pem file to .ppk file.
It’s necessary to have a key pair on Amazon EC2 in order to access the instances we run. Here we talk about how to create these key pairs. For these examples, we will need the AWS CLI or ec2-api-tools. A key pair is just an SSH key pair that we have registered with AWS, and it is necessary to have them even when running Microsoft Windows. Dec 11, 2013 I also generate private key pair using putty for our connection to the instance. Generating Key pairs from amazon ec2 console DBA Pro. SET UP INSTANCE ELASTIC IP AND KEY PAIR IN AMAZON.
Generate product key for windows 7. Mar 09, 2020 Overview of Windows 7 Product Key Generator Windows 7 is a generally accepted Windows worldwide. It is now widely considered as the Windows OS with the friendliest interface. This makes people have an interest in getting it installed on their laptop. Various kinds of people use it, both for personal works and for business-oriented programs. Nov 24, 2019 Windows 7 Product Key Generator 32/64 bit Working 100%. Windows 7 Product Key readily available for public use after three several years of the release of windows vista. It is completely updated and changed the system that is running the sooner incarnations of Windows. Jan 18, 2020 Windows 7 product key. The windows 7 product key verifies the windows 7 OS in use, is authentic and an original copy of the software. The windows 7 product key functions either on a 64 Bit version or the 32 Bit version. It is also important to note that the product keys can only be used to activate one software edition.
For this conversion, putty provides a tool called PuTTYgen.
1. Download AWS PEM file
In AWS, when you first create a key pair file, that you want to use for your EC2 instances, AWS will allow you to download the PEM file to your local machine. Save this PEM file somewhere on your machine.
In this example, the .pem file I have is called thegeekstuff.pem, which is under C drive.
We’ll be converting this thegeekstuff.pem file to thegeekstuff.ppk and use the .ppk to login to EC2 instance using PuTTY.
BTW, the steps to convert pem to ppk for putty is exactly the same for all the Linux AMI images, including CentOS, RedHat, Ubuntu, SuSE, Fedora, Amazon Linux, etc.
2. Download PuTTYGen
Download PuTTYgen from here.
If you’ve used the PuTTY MSI installer, then all the PuTTY utilities comes with it including puttygen.
If you are already using only putty.exe as a standalone, then you can also download the standalone puttygen.exe
Launch PuTTYgen by double clicking on it.
PuTTYGen is a RSA and DSA key generation utility. But, in our case, we’ll be using this to convert the pem to ppk file.
The main PuTTYGen screen will have the following three sections:
Key Section: This will display the current key that is loaded. i.e The key that you are currently working on. When you first launch the puttygen, this section will say “No Key”.
Actions Section: This section will display all the possible actions that you can perform inside PuTTYGen. The following are the available actions:
Add Public Key To Ec2
Parameters Section: Here you’ll specify the type of key to generate. You have three options here: SSH-1 (RSA), SSH-2 (RSA), SSH-2 DSA. You can also set the value of number of bits for the generated key. By default the type will be SSH-2 (RSA) and 2048-bit.
For our purpose of converting PEM to PPK, leave all the parameters at their default value. i.e SSH-2 (RSA) and 2048 bit.
See also: 10 Awesome PuTTY Tips and Tricks You Probably Didn’t Know
3. Load PEM file to PuTTYGen for Conversion
In the following PuTTYGen main screen, click on “Load” button, and select your AWS PEM file.
Please note that when you click on “Load”, in the file selection window, by default, it will show “PuTTY Private Key Files (*.ppk)” as the option. Click on this drop-down list and choose “All Files” as shown below. After this, you can browser to the directory where you *.pem file is located, and load it.
Once the *.pem file is loaded, you’ll get a pop-up message saying “Successfully imported foreign key (OpenSSH SSH-2 private key)”. Click on “OK” in this screen.
4. Save your Converted PPK Private Key
Now that we have the keys loaded, you’ll see in the top “Key” section, our key information will be displayed. This will display the key fingerprint, key comment. The key passphrase in this case will be empty, as we didn’t have any passphrase for our AWS PEM file in this example.
Also, in the action section, we’ll see the save button enabled.
Click on the “Save Private Key” button, to save our converted ppk private key.
Generate New Key Pair For Ec2 Instance Server
This will display a warning message saying: “Are you sure you want to save this key without a passphrase to protect it?”. Click on “YES”.
Now, give a name to this file. In our case, I’ve named this converted file as thegeekstuff.ppk
5. Use the PPK File in PuTTY
Now, that we have the thegeekstuff.pem AWS PEM file converted to thegeekstuff.ppk PuTTY key file, we can use this to login to our AWS EC2 instance.
For this, launch the putty, and do the following:
First, in the “Host Name (or IP address)” field, enter the public-dns or ip of your AWS EC2 instance.
Second, in the “Saved Sessions” field, enter the name that you would like to give for this AWS-EC2-instance on your putty, and click on “Save” to save this sessions in your putty list.
Third, on the left-hand side panel, expand the “Connections” -> expand “SSH” -> select “Auth”. Click on “Browse”, and select your converted ppk file for the “Private key file for authentication” as shown below.
Fourth, at this stage you can click on “Open” to start the connection, but you’ll lose the values that you just entered. So, on the left-panel click on “Sessions” again, and click on “Save” again. This will save the information about the private key that you provided to the putty-session that you saved earlier.
6. PEM and PPK File Formats
Once you’ve converted the file, you can view the content of PEM and PPK file in a text editor, and you’ll see that the content looks different, as they are of different formats.
PEM Key File from Aamazon EC2 (e.g: thegeekstuff.pem)
The PPK file format (e.g: thegeekstuff.pem). This is the file that we converted using PuTTYGen tool. This is the keyfile format that will work on your PuTTY to login to your Amazon AWS EC2 Linux instance using SSH protocol as shown above.
> Add your comment
If you enjoyed this article, you might also like.![]()
Next post: 8 PostgreSQL Examples to Install, Create DB & Table, Insert & Select Records
Previous post: 8 Steps to Install MirthConnect with MySQL / MariaDB on Linux
This article will discuss EC2 key pairs and how they can be used to connect to Windows and Linux instances.
Amazon AWS uses keys to encrypt and decrypt login information.
At the basic level, a sender uses a public key to encrypt data, which its receiver then decrypts using another private key. These two keys, public and private, are known as a key pair.
You need a key pair to be able to connect to your instances. The way this works on Linux and Windows instances is different.
First, when you launch a new instance, you assign a key pair to it. Then, when you log in to it, you use the private key.
The difference between Linux and Windows instances is that Linux instances do not have a password already set and you must use the key pair to log in to Linux instances. On the other hand, on Windows instances, you need the key pair to decrypt the administrator password. Using the decrypted password, you can use RDP and then connect to your Windows instance.
Amazon EC2 stores only the public key, and you can either generate it inside Amazon EC2 or you can import it. Since the private key is not stored by Amazon, it’s advisable to store it in a secure place as anyone who has this private key can log in on your behalf.
This article assumes that you don’t have any key pair created, hence no public or private keys (generated in AWS or imported) and no running Linux or Windows instances.
All of them will be created and you will be shown how to do so, and also how to connect to your Linux and Windows instances.
The first step is to create the key pair. From the EC2 panel under NETWORK & SECURITY, choose Key Pairs. Click on Create Key Pair, specify the name of the key pair and click on Create:
Once you do that, the private key is automatically saved by your browser. Save this file in a safe place as this is the only time you will have access to it:
Now that the key pair is created, it’s time to create two instances: one Linux instance and one Windows instance.
During the process of creating the instances, specifically at the very end of the instance launch, you will be asked if you want to use a key pair and if yes, to select an existing one or create a new one. As we already have one, we will use an existing one.
This is for the Linux instance:
And this is for the Windows instance:
After a few minutes, you should see both instances running:
Putty generate ssh key for linux. Generate RSA keys with SSH by using PuTTYgen. This means that a public key is placed onthe server and a private key is placed on your local workstation.Using a key pair makes it impossible for someone to log in by using justa password, as long as you set up SSH to deny password-basedauthentication.This article provides steps for generating RSA keys by using PuTTYgen onWindows for secure SSH authentication with OpenSSH. Last updated on: 2016-06-23. Authored by: Rackspace SupportOne effective way of securing SSH access to your cloud server is to usea public-private key pair.
Now that both instances are running, let’s connect to the Linux instance from a Linux host and also from a Windows host using PuTTY.
Check the public IP address assigned to the Linux instance: 54.208.108.66.
In order to connect to the Linux instance from a Linux host, you have to change the permissions of the key pair to 400, which means that the only permission is that it can be read by the owner of the file.
Below is an example of how you can connect from a Linux host to your Linux instance in AWS.
But what happens if you try to connect to the Linux instance from a Windows machine using PuTTY?
PuTTY does not support the .pem format generated by Amazon EC2 for the private key. It uses the .ppk format.
PuTTYgen is a tool that can be used to convert keys to the required PuTTY format .ppk.
Unless you convert the key generated by Amazon EC2, you will not be able to connect to the Linux instance using PuTTY.
![]()
Start PuTTYgen and load the private key downloaded earlier. Choose SSH-2 RSA with 1024 bits length.
Click on Save private key (because this is still a private key) to save it in a format that PuTTY can use.
You will be asked if you want to save the key without a passphrase (password). Choose Yes and specify the name of the private key.
Once the private key is saved, start PuTTY and provide the location of the private key:
And the username and hostname of the Linux instance:
You can now log in to the Linux instance:
It’s time to connect to the Windows instance. First we need to find out the administrator password.
Right click on the Windows instance and select Get Windows Password. You will be asked to provide the private key:
Click on Decrypt Password and the password will be shown in clear text. Write down the password as you will need it to connect using RDP to the Windows instance:
After that, you can RDP to the Windows instance, by using the IP address of the Windows instance 54.88.48.2, and change the administrator password:
As you can see, the key pairs are really important to EC2 instances. Without them you will not be able to connect to your instances or change passwords.
The most important thing to remember is that you shouldn’t lose the private keys, and that they should never get in the hands of anyone else that is not trusted by your organization. Otherwise, there might be unauthorized access to your instances and your data might be compromised or lost.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |