after installing the firewall can not log in with SSH

September 30, 2014 2.1k views


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

I followed this guide:

Thank you.


1 Answer

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 . .

Have another answer? Share your knowledge.