For security reasons I changed the port for an ssh login to a different port number. But as soon as I do and try to reconnect, I get a 'Connection timed out error'. Once I switch back to port 22 it all works fine. This is what I have done so far:
- Logged in to my VPS via using
ssh [email protected]
. - In /etc/ssh/ I changed the sshd_config file to set the port to 717.
- Restarted the ssh daemon using:
sudo systemctl restart sshd
- Verified that the ssh daemon is up and running using
systemctl status sshd
- Verified that port 22 isn't working anymore by trying to login on a 2nd terminal like in 1.
- This led to the expected
ssh: connect to host vps.ip.address port 22: Connection refused
- Tried to login via ssh using the port 717:
ssh [email protected] -p 717
- After some time I get as response:
ssh: connect to vps.ip.address port 717: Connection timed out
- Still in my active terminal session on my VPS verifying that server is correctly listening on port 717 :
sudo grep Port /etc/ssh/sshd_config
. The output was:
Port 717
#GatewayPorts no
- Checked the firewall settings to make sure there is no blocking of port 717:
sudo iptables -L
- This returned:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
- checked the /var/log/auth.log output to verify that is still listening on port 717:
Mar 13 08:18:20 localhost sshd[4883]: Server listening on 0.0.0.0 port 717.`
`Mar 13 08:18:20 localhost polkitd(authority=local): Unregistered Authentication Agent for unix-process:4863:4345392 (system bus name :1.35, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
- changed the port back to port 22 in /etc/ssh/sshd_config and restarted the ssh daemon
- login from a 2nd terminal via ssh just like under 1.
- successfully logged in again.
netstat
show