Changing SSH Ports for Provision

I’m looking to provision a Digital Ocean droplet to use a different SSH port other than 22. I changed the port for both sshd_ports and ssh_port in sshd/defaults/main.yml, and I can see the config files have the proper ports on the server.

However, whenever I try to connect to the new port I’m getting a connection refused. This doesn’t happen if I just change the SSH port on a vanilla, pre-provisioned server.

What am I missing?

Did you check ufw firewall rules on the VPS? See Setting up Firewall rules - #4 by fullyint and also see https://www.digitalocean.com/community/tutorials/opening-a-port-on-linux#opening-a-port-on-linux-to-allow-tcp-connections .

1 Like