Report this

What is the reason for this report?

How to change SSH port and firewall rule?

Posted on January 5, 2018

Hi, I have set up a different port for SSH(same way as it is described in the deprecated article) and custom firewall rule [TCP, all IP4/6] limited to the same port. I still can’t get connection[ssh: connect to host xx.xx.xx.xx port xxxx: Connection timed out]. What is the problem?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

To change the port ssh works on, edit /etc/ssh/sshd_config and edit the line “Port 22” to be a different port. Then restart sshd (“sudo service ssh restart”) You can then test whether ssh is working on that port with “ssh localhost -p 1234” or whatever your new port is.

If that works, but remotely doesn’t work it’s probably the firewall issue. How do you have your firewall set up? The firewall from Digital Ocean’s control panel? UFW? IPTables?

Helo LampreyOne,

Thanks a lot, for your tip. I’ve been blocked to acces my droplet after the FIREWAL installation. Then your solution was my salvation.

Sincerelly,

luciano viterbo

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.