I accidentally changed the permissions of .ssh directory and everything inside of it to 777 in my ec2 instance as ec2-user (root) and logged out of the instance. Now I cannot ssh into my instance since the permissions are too open. Is there anything I can do without creating a new instance? I have access to other users in the same instance.
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
If you’ve got another user with SSH access to the instance you can log in using that user account.
Note if the permissions issue only affects the
ec2-user
account, you can log in with the other user and should be able to fix the permissions.Also note you can use the EC2 Serial Console to troubleshoot issues with your instance, even if you can’t SSH into it.
Did you try to use AWS Systems Manager (SSM) to access the instance
and fix the permissions
Try detaching the root EBS volume from this instance and attaching it to another instance as a secondary volume. You could then correct the permissions directly from the other instance.
if you have another user with sudo
privileges, login with that user – let’s say ec2-user and do the
below steps
these should help