Locked myself out of SSH with UFW in EC2 AWS

后端 未结 6 909
孤城傲影
孤城傲影 2020-12-04 14:38

I have an EC2 Instance with Ubuntu. I used sudo ufw enable and after only allow the mongodb port

sudo ufw allow 27017

When th

6条回答
  •  天命终不由人
    2020-12-04 15:06

    • Launch another EC2 server instance The best way to accomplish this is use EC2’s “Launch More Like This” feature. This will ensure that the OS type, security group and other attributes are the same thus saving a bit of setup time.
    • Stop the problem instance
    • Detach volume from problem instance
    • Attach volume to new instance

    Note: Newer Linux kernels may rename your devices to /dev/xvdf through /dev/xvdp internally, even when the device name entered is /dev/sdf through /dev/sdp.

    • Mount the volume
    cd ~
    mkdir lnx1
    sudo mount /dev/xvdf ./lnx1
    
    • Disable UFW
    cd lnx1
    sudo vim ufw.conf
    

    Now find ENABLED=yes and change it to ENABLED=no.

    • Detach volume

    Be sure to unmount the volume first:

    sudo umount ./lnx1/
    
    • Reattach the volume to /dev/sda1 on our problem instance
    • Boot problem instance
    • Reassign elastic IP address if necessary
    • Delete the temporary instance and its associated volume

    Hola !! you are good go.

提交回复
热议问题