Me and my friend are working on AWS EC2 first time and using their free tier plan for 1st year.
Both of us have MAC and my friend has created EC2 instance & key pair.
My query is how can I export that key pair to my local machine as I need to do SSH to EC2 instance.
Or do I need to create new key pair ?
Related
Do EC2 instances automatically save changes made inside a running instance?
For example, after creating an EC2 Windows 2019 instance, I login as Administrator using RDP and install some software. If the EC2 instance is terminated or rebooted, will the software still be installed when I restart the EC2 instance?
In layman terms, you should consider your EC2 instance as a new virtual machine running on cloud. Terminate is used to delete an EC2 instance. AWS docs say:
An instance reboot is equivalent to an operating system reboot. In most cases, it takes only a few minutes to reboot your instance. When you reboot an instance, it keeps its public DNS name (IPv4), private IPv4 address, IPv6 address (if applicable), and any data on its instance store volumes.
If you terminate the instance its lost but if you restart the instance all the installed softwares will be there but if you want to create another instance with the same packages installed then you can create AMI out of instance and next time use that AMI to create new instance and all softwares will be preinstalled in the new win instance
I am running an AWS EC2 VM for a school project. I accidentally deleted the local key pair on my computer then emptied my recycle bin on my Mac. I dont see a way to redownload the keypair.
There are important things running on the VM that I need.
Is it possible to redownload the local keypair?
I cant even seem to regenerate a new keypair to that instance.
There are two ways to recover the access.
AWS Systems Manager (SSM) automation
To recover access to your Linux instance using AWS Systems Manager (SSM) automation, run the AWSSupport-ResetAccess Automation automation document. For more information, see Reset Passwords and SSH Keys on Amazon EC2 Instances.
Manually recover access
To manually recover access to your Linux instance, create a new key pair to replace the lost key pair. For more information, see Connecting to Your Linux Instance If You Lose Your Private Key.
What will happen if you lost the ssh key pair of a Linux instance? should you be able to get it back by contacting the Alibaba cloud support.
The best way would be to reset the password and connect. Once you are in root you should be able to create a snapshot and restore it with a new instance.
You will find the "Reset Password" under Console > Click on Instance> Instance Details> More> Reset Password
The Alibaba Cloud CLI supports replacing an ECS instance keypair.
Step 1: Go the the Alibaba Console and look up the instance ID for your instance.
Step 2: Generate a new keypair:
aliyuncli ecs CreateKeyPair --RegionId us-west-1 --KeyPairName mykeypair
Step 3: Attach the keypair using the CLI:
aliyuncli ecs AttachKeyPair --RegionId us-west-1 --KeyPairName mykeypair --InstanceIds "[\"i-abcdeftvgllm854abcde\"]"
Step 4: Reboot the instance.
aliyuncli ecs RebootInstance --InstanceId i-abcdeftvgllm854abcde
I wrote an article for Alibaba on exactly this topic:
https://www.neoprime.io/info/alibaba/devops/day_02.php
The answer is no.
In such case, you have to create an ECS instance for this purpose.
Steps to recover ssh key pair.
create a new instance in any Region/Zone.
stop the old instance and de-attach it’s root EBS volume and attach it to the new instance as a secondary volume.
then login to the new instance and switch to root and create a mount point.
for ex:
lsblk
mkdir /mnt/recovery
lsblk
mount /dev/xvdf1 /mnt/recovery (here /dev/xvdf1 is secondary disk)
now append the .ssh authorized key file
cat /home/ubuntu/.ssh/authorized_keys > /mnt/recovery/home/ubuntu/.ssh/authorized_keys
Update the volume of the old instance (i.e., currently secondary disk) with the new instance’s key ssh key file.
now unmount the secondary disk
unmount /mnt/recovery/
Stop the new instance.
de-attach secondary volume from the new instance and then attach it back to the old instance as root volume /dev/xvda
start the old instance log in with new ssh key pair
ssh ubuntu#192.168.0.10 –i new-keypair.ppk
Done!
Not sure if Alibaba Cloud Support can help you with recovering a lost SSH Key pair. My best advise is to reset the instance password: https://www.alibabacloud.com/help/doc-detail/25439.htm
Also you can contact the support team if you wish and see what help they can offer.
I have a instance in AWS EC2 A account,
I want to move it From AWS EC2 A account to AWS EC2 B account,
but the instance IP can not be changed,how do i do it?
Thank you.
That's not possible.
Instances cannot be moved across account boundaries, they can only be clones.
Elastic IPs also cannot be moved.
Your service should use DNS names and not be dependent on a fixed IP address.
My goal is to launch 200 instance of windows node of the same ami in aws. These node come up and connect to my head node. Now, every launch of a new node create a new password for that node. This is hard to manage specially if I want to do group remote maitenance.
I was thinking, maybe I can make all of specific ami to have the same password but do I do that ? Should I modify sysprep condfig file C:\Program Files\Amazon\Ec2ConfigService\sysprep2008.xml or should I disable both set password for the ec2 config tool and then create a AMI?
If the config file, what exactly should I put in the sysprep2008.xml file?