Ask HN: Enable a Linux firewall without locking yourself out?
sudo ufw allow from his-ip-address sudo ufw allow ssh sudo ufw enable
It ended up costing him over £200 to pay for out-of-hours support for an engineer to drive to the data centre and restart the server.
He still needs to enable the firewall, but is very worried about getting locked out again. How can he do this without locking himself out?
My initial ideas are :
1. have a crontab that runs every 10 minutes to disable the firewall. Then enable the firewall, test he can still gain access. If not, worst case he is locked out for 10 minutes
2. run a shell script that enables the firewall, sleeps for a few minutes, and then disables it This would need to run in something like tmux so that when the session is killed by the firewall the script will continue running
Is there a better way?
I have already suggested he take a look at moving to AWS - but that may take some time.
Thanks
7 comments
[ 2.7 ms ] story [ 28.4 ms ] threadi can highly recommend to directly use iptables and take a look at the arch linux wiki and especially this site https://wiki.archlinux.org/index.php/Simple_stateful_firewal...
Thanks