Change the SSH Port On Ubuntu

For example, changing the default ssh port to use 20040 instead of 22…

  1. Edit /etc/ssh/sshd_config, uncomment the line Port 22 to say Port 20040
  2. sudo sytemctl restart ssh
  3. Run netstat -tulpn | grep ssh and make sure ssh is listening on 20040
  4. Make sure ubuntu firewall allows it, run sudo ufw allow 20040/tcp
  5. Lastly, make sure you have your cloud level firewall rules also set up to allow access to that port.
end of storey Last modified: