Changing SSH port on ubuntu 14.04 server fails

June 20, 2014 12.7k views
i followed this tutorial step by step, and I changed the ssh port to something else but when I ssh it it, it wont work anymore, I also tried to add it to firewall using the following commands: $: iptables -A INPUT -p tcp -m tcp --dport 25000 -j ACCEPT $: iptables-save but still I can not SSH to my droplet, it wont even ask my username, it just times out
4 Answers
Did you restart ssh after changing the port? sudo service ssh restart
Do you currently still have ssh root access?
jt, yes I did restart ssh info, I did not have SSH access at all, neither root nor non-root, I deleted the whole droplet, I created it many times, and re did everything...nothing works, I tried on both 12.04 and 14.04 ubuntu
  • In <code>/etc/ssh/sshd_config</code>, make sure your user is listed among <code>AllowUsers</code>

First check that your sshd is up and serving on port 25000 with the following command
ss -nlput | grep sshd
netstat -np tcp | find "25000"

If it is, and you’re still unable to connect with it, there’s a chance, that your ISP is blocking that port. Change the port to something more unique than equal thousand, like 38621.

Try also adding your ip/subnet to /etc/hosts.allow and cat /etc/hosts.deny if it has your ip in it.

Have another answer? Share your knowledge.