Search code examples
amazon-web-servicesamazon-ec2sshamazon-cloudfront

AWS EC2 + Cloudfront - Can I SSH in via CloudFront without a keypair?


I have inherited a webserver on AWS running an EC2 instance which is inherited via CloudFront.

I want to SSH in, but there is no keypair assigned to the EC2 instance. The previous dev is not very helpful - all he told me was "use cloudfront".

Looking into CloudFront - I saw nothing that indicated I could SSH in that way. Did I miss something? Is it possible for me to access the instance via SSH without a private key via Cloudfront?

I would appreciate any help


Solution

  • You can't ssh into your instance through CloudFront. If you don't have the private key to ssh, there are some options you can use:

    1. Try EC2 Instance Connect which is a web-based ssh client. It will not ask for private key, if it works.

    2. Try AWS Systems Manager Session Manager which is also web client. This will work even if the instance was launched without any ssh client. You will need to read up on how to set it up as it requires special instance role, and the ability of the instance to connect to the SSM service.

    3. Use AWSSupport-ResetAccess SSM Automation to reset the ssh key for the instance.

    4. Use recovery instance as shown in the official AWS video.

    The best options would be to try 2 and 1. But depending on how the instance is setup, is it in private or public subnet, does it have internet access, is it Amazon Linux 2 or some non-standard AMI, what kind of roles it has, etc., you may need to perform extra steps to make it work.

    Options 3 and 4 will require downtime and making backup before you attempt them would be good choice. Options 1 and 2 may work without any downtime, depending on the instance current setup.