How to recover lost ssh access to amazon EC2 instance

This article explains the steps to recover lost ssh access to amazon EC2 instance. Here in this case the server went inaccessible after the reboot due to the incorrect mount configuration.

Step1: Login to the AWS EC2 console.

Step2: Stop the instance if its running.

Step3: Detach the volume from the instance.

Step4: Create new instance for mounting the EBS volume temporarily.

Step5: Attach the EBS volume of older instance to this newly created instance as the secondary disk.

Step6: Mount the EBS volume to /mnt.

Step7: Access the mount configuration 'fstab' in secondary EBS volume and correct the error.

Step8: Unmount the EBS volume mounted to /mnt.

Step9: Detach the secondary EBS volume from the temporary instance.

Step10: Reattach EBS volume to the original instance as the root volume.

Step11: Start the instance and it will be accessible now.

Step12: Terminate the temporay instance as its not required.

Please note that the same procedure can be used in all case where the access to EC2 instance lost. We can fix the issues or even recover data by attaching the EBS volume to another instance.

That's all…