I'm trying to help a friend recover access to an EC2 instance where the private key was lost (is there possibly another way to access to make changes to content? Maybe the answer is more simple and right in front of my face). I followed the following steps accordingly, except for step 7 because I am getting refused:
- Stop the EC2 Linux Instance
- Detach the Root Volume
- Launching a new Temporary Instance
- Attach the Root Volume to New Instance
- Modify the authorized_keys File
- Reattach the Root Volume to the Original Instance
- Start and Connect the Original Instance with New Private Key
What stands out to me was that on step 5 I had to change the permissions of the /ec2-user directory, the /.ssh directory, and the file /.ssh/authorized_keys file to modify the keys.
When I tried step 7, I'm getting refused but I remember that the permissions for the authorized_keys file was set to rw------- (600) and I'm thinking that it needs to be increase. I could do 777 but that's terrible. Am I correct in my assumption? If so, what permission should I set? If not, any advice?