Tag Archives: port

Guide on changing SSH port and opening new port

1.) Check the port to be used if its already in use or not: netstat -nap | grep port#
2.) Open the port to be used:
– if using CSF, add the port on “Firewall Configuration”, put it on TCP_IN and TCP_OUT, restart CSF.
– you may use iptables manually: iptables -A INPUT -p tcp –dport port# -j ACCEPT
3.) Save changes by issuing: “service iptables save”, don’t flush iptables this may bring the serve down, it happened to me :):)
4.) Edit SSH config (/etc/ssh/sshd_config), and comment our the “#Port 22” and change that to the new port. Please comment out “#Protocol 2,1” and use “Protocol 2” for security.
5.) Reload SSH config, “service sshd reload”, and restart SSH, “service sshd restart”.
Note: when restarting SSH for applying the new port please open another Putty window. Just in case you experience problem you still have an open SSH window. Don’t restart via WHM, this will close all open SSH window (putty), and this will present you a message that SSH didn’t started ok, but its running. Just try to login on the new SSH port.