Question

How to change SSH port and firewall rule?

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

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

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?