I got locked out of my amazon instance. I read that I can create a new instance and attach that volume to the new instance. I attached the old volume to the new instance and the management console says its at /dev/sdf. My question is how do I access that volume ? I read that I can access it by mounting. I tried doing this

sudo mount /dev/sdf ~/vol1/

but I get the error

[root@ip-172-31-42-113 ~]# sudo mount /dev/sdf ~/vol1/
mount: wrong fstype, bad option, bad superblock on /dev/xvdf,
       missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
       dmesg | tail or so.

Any suggestions on how I can access that volume ? I need to change the permissions of home/ec2-user of that volume. Apparently I set it to 777 and because of the relaxed permission setting I think I got locked out of it ? Also can you tell me what the default permission for home/ec2-user should be ?


There will most likely be a partition /dev/sdf1 (notice the 1) so you have to mount that:

~ $ sudo mount /dev/sdf1 ~/vol1

Then change what you need to change (e.g. add your new, working, ssh key to ~/vol1/home/ec2-user/.ssh/authorized_keys) and unmount is again with:

~ $ sudo umount ~/vol1

Finally re-attach it to your old instance as /dev/sda1 (or /dev/xvda1, depending on what it was before) - even if that device name is not offered in the drop-down list. Just type it in when attaching the volume.

Hope that helps :)

  • yes thank you. I am able to access it. Can you tell me what the default permission for home/ec2-user should be ? I accidentally changed it to 777 and I believe that was the reason I got locked out. I am not sure what the default for it was or what I should change it to ? – MistyD Nov 26 '18 at 23:06
  • Create a new small instance to see a working example. Increase the LogLevel setting of sshd to check if it complains about there permissions on any home directories. – John Mahowald Nov 26 '18 at 23:28
  • @MistyD change it to 700, that will do. – MLu Nov 26 '18 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.