skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
    • 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

       sudo su
      
       chmod 700 /home/ec2-user/.ssh #     Fix permissions
      
       chmod 600 /home/ec2-user/.ssh/*
       chmod 644 /home/ec2-user/.ssh/*.pub
      
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search