if ufw enable and ssh not login problem, how to solve it?

try this.

Launch a new instance (recovery instance).
Stop the original instance (DO NOT TERMINATE)
Detach the volume (problem volume) from the original instance
Attached it to the recovery instance as /dev/sdf.
Login to the recovery instance via ssh/putty
Run sudo lsblk to display attached volumes and confirm the name of the problem volume. It usually begins with /dev/xvdf. Mine is /dev/xvdf1
Mount problem volume.

$ sudo mount /dev/xvdf1 /mnt
$ cd /mnt/etc/ufw

Open ufw configuration file

$ sudo vim ufw.conf

Press i to edit the file.
Change ENABLED=yes to ENABLED=no
Type Ctrl-C and type :wq to save the file.
Display content of ufw conf file using the command below and ensure that ENABLED=yes has been changed to ENABLED=no

$ sudo cat ufw.conf 

Unmount volume

$ cd ~
$ sudo umount /mnt

Detach problem volume from recovery instance and re-attach it to the original instance as /dev/sda1.

Start the original instance and you should be able to log back in