Search code examples
linuxamazon-web-servicesamazon-ec2hosts-file

Wrong entry in /etc/deny.hosts file


I mistakenly edited the /etc/deny.hosts file and added following entry-
ALL: ALL. Now, I'm unable to do SSH into it. After searching, I found that it denies all users from accessing the system. Does any one have idea on how to overcome this?


Solution

  • If the Root device of the Instance is an EBS, below steps will help you to come out of the situation.

    • Stop the Instance (Instance1)
    • Detach the Root Volume
    • Attach the Volume to a different running Instance (Instance2) as a non-Root device.
    • Mount the device on Instance2
      • Find the newly attached volume name using lsblk and then try to mount the volume.
    • Edit the deny.hosts file, it will be under /mountpath/etc/deny.hosts
    • Detach the Volume from Instance2 and re-Attach it to the Instance1 as Root Device.