Order

Help

UFW blocked SSH: how to get back into the server

If the server stopped accepting SSH after ufw was turned on, you can get back in through the console in the panel. The system stays as it was, no reinstall is needed.

Why access was lost

ufw enable run without allowing port 22 closes every incoming connection. Your current session may still work, but a new SSH connection will not get through.

How to get back in

  1. Open the server's page in the panel.
  2. Press Console, then Open the console.
  3. Sign in as root with the password from the panel.
  4. Run one of the commands below.
  5. Try to connect over SSH from your computer.

The console link lives for a few minutes. If it has expired, open the console again.

Which command to pick

To keep the firewall on with SSH working:

ufw allow 22/tcp && ufw enable

If you do not need the firewall yet, turn it off:

ufw disable

If your SSH runs on another port, allow that port instead of 22.

How to turn ufw on the right way

The order matters: allow SSH first, then turn the firewall on.

  1. ufw allow 22/tcp
  2. ufw enable
  3. ufw status

In the output of ufw status check that the SSH port is in the allowed list. Only then close your current session.

Questions

Do I have to reinstall the system if ufw closed SSH?

No. Sign in through the console in the panel and change the ufw rules.

Which password does the console take?

Sign in as root with the password from the panel.

The console link stopped working. What now?

It lives for a few minutes. Press Console, then Open the console on the server's page again.

More in the help