After activating firewall of remote server I can not login with ssh

Hello,
On ubuntu 16 I have php/laravel app installed under appache .
I have firewall inactive and I decided to activate it and rebooted the OS

 sudo ufw status numbered
Status: inactive
root@ubuntu-server/app# sudo ufw default deny incoming
Default incoming policy changed to 'deny'
(be sure to update your rules accordingly)
root@ubuntu-server/app# sudo ufw default allow outgoing
Default outgoing policy changed to 'allow'
(be sure to update your rules accordingly)
root@ubuntu-server/app# sudo ufw status numbered
Status: inactive
root@ubuntu-server/app# sudo ufw status verbose
Status: inactive
root@ubuntu-server/app# reboot
Connection to NNN.NNN.NN.NN closed by remote host.
Connection to NNN.NNN.NN.NN closed.

But after that I can not to log unto the system with ssh:

ssh root@NNN.NNN.NN.NN
ssh: connect to host NNN.NNN.NN.NN port 22: Connection timed out

If my commands were invalid and if there is a way to enter into it now ?

I can not enter into the system with ssh but also in the browser site is not opened.
Looks like problems on restarting. That is Ubuntu under Digital Ocean and I have access to Digital Ocean account.
Which steps have i to tale to fix server ?

Thanks!

Hi,

You should be able to allow or deny by service name since ufw reads from /etc/services.

To allow a service by name:

sudo ufw allow <service name>

So, for ssh, that would be:

sudo ufw allow ssh

Further reading: https://help.ubuntu.com/community/UFW

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.