Restoring access to Amazon EC2 instance with the loss of a. pem file
Once Ubuntu on my laptop has stopped running, swearing in corrupted xfs on disk. Moreover, it contains a project I'm working on. There was, however, a git repository on the EC2 machine, but the. pem file lying on the same drive.
I will mention that do not put on the FTP server access via SFTP it would be impossible to obtain without a key.
Of course you can speak about the virtues of backups, but I had to find a way to restore access to a cloud machine, not to lose the work done.
Long enough exploring the AWS Management Console to determine how to recover. pem file, I found that it seems to be impossible, Amazon does not store it. When you create a new instance of the console prompts you to select an already created key, or create new ones.

If the existing system is not stored to the project files I could safely delete the machine and create a new one with a new pem file.
And then I remembered about the wonderful opportunities afforded by the AWS — creating a custom image (AMI). The essence of this feature is that you can install the whole set needed FOR one instance, saving an AMI using it to create a series of similar machines. You can deploy to EC2 cluster from a single image, or make a save state of the machine.
Elastic IPS
Elastic IP allows you to reserve IP address for Your account, assign it to any of the machines. In my case the IP reservation was a necessary measure, since the car was already set up with DNS, which did not want to reconfigure. However, as I understand, when you reserve issued a new IP, so you don't have to reserve the ip given at machine startup. So, if You have not attended a reservation for the address before, or his shift is not critical, this item can be omitted.
If you pre-reserve IP, this service will allow to replace the machine unbeknownst to the outside world. Recommend it to use, Amazon takes the money just for a simple IP address, i.e. when it is not attached to a working machine (same IP, you will be able to see here).
Managing backup and IP binding can be produced in the console (EC2 / NETWORK &SECURITY / Elastic IPs).
AMI
As I wrote, AMI will keep everything that was already on the disk of the machine (installed and configured software, databases, your files).
To create an image go to the EC2 section of the AWS management console, select Instances. Click the right mouse button on the instance to which you lost access, choose from context menu "Create Image (EBS AMI)".

In the window that appears write the name of the AMI that you specify the necessary options. Here you should pay attention to the users of the Free Tier, nasonovskii annual freebies. It is necessary that Your AMI image in the sum image of the existing machine, not exceed free tairovski limit on EBS (Elastic Block Store), which, at the time of writing, equal to 30 GB.
use
There are two ways to raise the car from our AMI via EC2 / Instances / Launch Instance, when you select AMI go to the tab My AMI's, or choose the AMIs tab of the console the right way and in the context menu, click Launch Instance.

When you select a Key Pair for the car(see first screenshot), create a new pem file, load it, and start the machine.
If you are using Elastic IP, untie it from the old machine to link to a new one.
Old car (by connecting to new, making sure everything is turned) can be removed. AMI can also be deleted in AMIs choosing for it a De-register.
UPD: astlock suggested another option:
The difference: application of the latter method is associated with a slightly greater inaccessibility of services, for instance related to the time spent on these operations. My method reduces that time to the minimum necessary to remapping elastic ip.
Article based on information from habrahabr.ru
I will mention that do not put on the FTP server access via SFTP it would be impossible to obtain without a key.
Of course you can speak about the virtues of backups, but I had to find a way to restore access to a cloud machine, not to lose the work done.
Long enough exploring the AWS Management Console to determine how to recover. pem file, I found that it seems to be impossible, Amazon does not store it. When you create a new instance of the console prompts you to select an already created key, or create new ones.

If the existing system is not stored to the project files I could safely delete the machine and create a new one with a new pem file.
And then I remembered about the wonderful opportunities afforded by the AWS — creating a custom image (AMI). The essence of this feature is that you can install the whole set needed FOR one instance, saving an AMI using it to create a series of similar machines. You can deploy to EC2 cluster from a single image, or make a save state of the machine.
Elastic IPS
Elastic IP allows you to reserve IP address for Your account, assign it to any of the machines. In my case the IP reservation was a necessary measure, since the car was already set up with DNS, which did not want to reconfigure. However, as I understand, when you reserve issued a new IP, so you don't have to reserve the ip given at machine startup. So, if You have not attended a reservation for the address before, or his shift is not critical, this item can be omitted.
If you pre-reserve IP, this service will allow to replace the machine unbeknownst to the outside world. Recommend it to use, Amazon takes the money just for a simple IP address, i.e. when it is not attached to a working machine (same IP, you will be able to see here).
Managing backup and IP binding can be produced in the console (EC2 / NETWORK &SECURITY / Elastic IPs).
AMI
As I wrote, AMI will keep everything that was already on the disk of the machine (installed and configured software, databases, your files).
To create an image go to the EC2 section of the AWS management console, select Instances. Click the right mouse button on the instance to which you lost access, choose from context menu "Create Image (EBS AMI)".

In the window that appears write the name of the AMI that you specify the necessary options. Here you should pay attention to the users of the Free Tier, nasonovskii annual freebies. It is necessary that Your AMI image in the sum image of the existing machine, not exceed free tairovski limit on EBS (Elastic Block Store), which, at the time of writing, equal to 30 GB.
use
There are two ways to raise the car from our AMI via EC2 / Instances / Launch Instance, when you select AMI go to the tab My AMI's, or choose the AMIs tab of the console the right way and in the context menu, click Launch Instance.

When you select a Key Pair for the car(see first screenshot), create a new pem file, load it, and start the machine.
If you are using Elastic IP, untie it from the old machine to link to a new one.
Old car (by connecting to new, making sure everything is turned) can be removed. AMI can also be deleted in AMIs choosing for it a De-register.
UPD: astlock suggested another option:
-Stopes instance
-raise any new ones from any image
-rule authorized_keys, insert your key
-ommunities disk, kill the temporary instance
-Mountie old include, connecticity with the new key.
The difference: application of the latter method is associated with a slightly greater inaccessibility of services, for instance related to the time spent on these operations. My method reduces that time to the minimum necessary to remapping elastic ip.
Комментарии
Отправить комментарий