after installing the firewall can not log in with SSH

September 30, 2014 23.3k views


I installed the firewall but now I can not access with SSH. Please what should I do?

I followed this guide:

Thank you.


2 Answers

Before enabling the firewall, did you open a port in order to access the server using SSH? Normally this would be port 22. You can open it with:

sudo ufw allow ssh

But if you’ve changed your ssh port to something else, you’ll need to specify it explicitly. For instance, if you’ve changed it to 2222:

sudo ufw allow 2222/tcp

You should be able to access your droplet via the web console in order to add new rules.

  • oops!

    I almost did that very thing yesterday (lock myself out of my droplet). Fortunately it entered my head to add the alternative ssh port before I exited.

    Good to know the web-console is there. I had not noticed that. I imagine the web-console runs from localhost so we can get in even if we messed up our ports?

  • please i can copy and paste the password into the Web Console? Can not log in with the Web Console because I have a very complicated password..

    Thank you.


  • Unfortunately it is not possible to copy/paste text from/to the remote console. I would suggest typing your password in manually, fixing SSH access, and then switching to SSH.

  • Does not look like pasting works…maybe have a friend read the characters to you while you type

  • The remote console connects to your droplet through the hypervisor, so even if you lock down ssh completely, including localhost, you will still be able to access your droplet as if you had a monitor and keyboard connected straight to it. :)

  • I was able to access… Thank you!

  • Thanks a lot . . you made my day . .

  • I have the same issue with it and this tip is succeeded for me.
    Thank you asb.

  • I couldn’t even use web console that also seems like not working i cant type anything there

Have another answer? Share your knowledge.