Change SSH Port on Ubuntu
列印- ubuntu, change ssh port, ubuntu server, ssh port, sshd_config, ssh configuration, server hardening, linux security, port 22, secure ssh
- 0
This guide shows you how to change the default SSH port on Ubuntu to a custom port (e.g., 2222) to improve server security against automated attacks.
Why Change the SSH Port?
Port 22 is the default SSH port and is commonly targeted by brute-force attacks. Changing the port reduces exposure and adds a layer of obscurity.
Steps to Change the SSH Port:
- Open the SSH configuration file: sudo nano /etc/ssh/sshd_config
- Find the line: #Port 22
 Uncomment it and change to a new port:Port 2222
- Allow the new port in the firewall: sudo ufw allow 2222
- Restart the SSH service: sudo systemctl restart ssh
- Important: Do not close your current session before testing the new port. You may also keep port 22 temporarily open as a fallback.
Watch the full tutorial:
https://www.youtube.com/watch?v=BUlhrUgve8c

