0

I'm trying to block all connectivity except what's required for a SSH server to function using the following commands on a freshly installed ubuntu 18.04 server:

sudo ufw allow ssh
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw enable && sudo ufw reload

After executing the commands, ssh remains open and firewall functions as expected. However, on reboot I get connection refused. I believe i have used these exact commands successfully on other providers but can't get it to work for my VPS on google cloud platform. Any ideas appreciated.

  • yes i'm trying to run ssh on port 22 which instantly gets refused on connection attempt
  • Please include the output of ufw status numbered after setting up the rules, before rebooting. You should try ufw default deny; ufw allow 22 which should be enough for your usecase. – Panki Sep 28 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.