I enabled the UFW firewall using SSH on my server at Digital Ocean running sudo ufw enable. and forgot to allow the ports for SSH, FTP, ... (but allowed port 80).

How can I SSH into the server or reset the firewall? Now I can't do anything, neither through SSH nor through FTP.

The root account is enabled and I know it's password, I also know the IP address.

  • 1
    TTY interface (virtual or physical) or something through your ISP. – Paul Nov 25 '15 at 7:45

You don't need ssh access, Digital Ocean provide console access to your system. You can use this to log in and fix your rules.

To access the console click Droplets -> Name of your system, this will take you to a page with a large friendly blue button called Console Access.

Friendly Blue Button

Click the blue button to get a console. Once you're in, you can change the rules and test them from outside using ssh.

If you need to, you can reset the root password. That's available on the same page as the blue button.


Did you save your firewall config so it would be applied on boot? If not, hopefully a reboot will clear the rules. If so, you really only have two options:

  1. If your host gives you out-of-band console access, then you can use that to fix your server.
  2. If not, perhaps they have some sort of recovery image you can boot your server from.

If neither of these are an option, then you're screwed.

  • I config by ssh // sudo ufw enable // sudo ufw allow 80 // sudo ufw allow 465 Because I need to config SMTP port and logout from ssh T^T – Chidkai Nov 25 '15 at 4:40
  • Well, then those rules will be applied on boot. Looks like you will need to recover your server using one of the methods I listed above. – EEAA Nov 25 '15 at 4:41
  • then you're screwed. – Gene Nov 25 '15 at 5:01
  • @Chidkai I'm assuming you're using a fresh system (you're still configuring SSH rules). Just launch a new one and delete the current one if it's not too much hassle. Recovering the instance would require more effort depending on the host. – Gene Nov 25 '15 at 5:03

check out this link if you are using amazon aws.. How to disable UFW ubuntu externally?

If you are using rackspace then you will have a terminal in the dashboard which will allow you in and then disable the UFW.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.