Linux – Login problems after changing default port ssh

debianlinuxportssh

I changed the Port in sshd_config file and restart the service (Using Linux Debian 8).
Logged out from SSH (Putty) and I tried to login later but I can't connect through Putty anymore.. I tried to login by FTP with FileZilla and that still works..

What is the problem?

Best Answer

I assume iptables are not running and blocking it. It could be SE Linux. Try running:

sestatus

If it is enabled, then run:

semanage port -l | grep ssh

And if the output says tcp 22

then run the following to add the new port (e.g. 2222)

semanage port -a -t ssh_port_t -p tcp 2222

then finally run

semanage port -l | grep ssh

which should then show 22 and 2222

and then it should work. If not then look into iptables:

iptables -nvL

will give you a list of what you have

iptables -A INPUT -p tcp --dport 2222 -j ACCEPT

would add a rule allowing traffic into port 2222, but this may not help depending on what other rules are present.

If iptables doesn't fix it then it could be a firewall between you and the server.

Related Topic