Background: I'm setting up a new 12.04 instance on a VPS with a new provider.The VPS provider only offers a 32bit image but that really shouldn't matter here. I have no local access to the machine and there is no rescue system; every time I try something I have to use their web admin tools to reinstall the image.
Problem: Every time I try to install and setup UFW I end up being locked out of the server. Here are the commands I've been running:
locale-gen "en_US.UTF-8"
locale-gen "en_CA.UTF-8"
apt-get update
apt-get -y upgrade
apt-get -y install nano ufw git
ufw allow ssh
ufw allow sftp
ufw allow ftp
ufw allow smtp
ufw allow "Apache Full"
ufw allow out 53
ufw enable
I've also tried first running the defaults
sudo ufw default deny incoming
sudo ufw default deny outgoing
As well as making sure that -A ufw-user-input -p tcp --dport 22 -j ACCEPT
is in /lib/ufw/user.rules
In all cases and every combination I've tried I end up losing the connection to the server and being totally locked out. I've had to reinstall the image about 5 times now. This is my fourth Ubuntu 12.04 server but for some reason it's totally different than the others. All of the others are running UFW with no problems. I also tried all of the above steps on a Debian 7 64bit image with this VPS provider but had the same problem.
What's going on here?