Can SSH to EC2 But Forgot Account
Solution 1:
Since you've got access to the instance you can simply shut it down - problem (almost) solved as shut down instances don't cost money.
[ec2-user@i-1234.... ~]$ sudo poweroff
You'll still have the disk (EBS volume) left behind - the cost is $0.10/GB/month and you pay for it even if the instance if stopped.
Before you shut it down find out what's the account id and instance id and record it for later:
[ec2-user@i-1234.... ~]$ curl http://169.254.169.254/latest/meta-data/iam/info
{
"Code" : "Success",
"LastUpdated" : "2019-01-18T20:30:58Z",
"InstanceProfileArn" : "arn:aws:iam::123456789012:instance-profile/...",
"InstanceProfileId" : "AIPA..."
}
That 123456789012
in InstanceProfileArn
is the AWS Account Id. You may need to that to find out the email address through AWS support.
Also record the Instance Id just in case:
[ec2-user@i-1234.... ~]$ curl http://169.254.169.254/latest/meta-data/instance-id
i-abcd1234abcd1234
Be prepared that it will be a struggle to get AWS to close or restore your access to that account. They are very difficult in these cases.
It may actually be much easier to get your credit card cancelled and let AWS close it for non-payment ;)
Hope that helps!
Solution 2:
You will have to submit a support request through AWS Contact Us page. Open the I cannot login to my AWS Account and then Lost account information.
Hope that helps :)