Easily and safely change your SSH port on any Linux VPS or dedicated server. This script supports Ubuntu, Debian, CentOS, and AlmaLinux, and also handles firewall rules and SELinux policies automatically.
Changing your SSH port may lock you out of your server if not done properly. Please ensure you have VNC, IPMI, or console access before using this script.
- Ubuntu 20.04 / 22.04
- Debian 11 and above
- CentOS 7 / 8
- AlmaLinux 8 / 9
- Prompts until valid SSH port is entered
- Updates
sshd_config
with new port - Opens the new port via:
- UFW (Ubuntu/Debian)
- Firewalld or iptables (CentOS/AlmaLinux)
- Automatically handles SELinux context updates
- Restarts SSH service without needing reboot
wget https://raw.githubusercontent.com/hosteons/ssh-port-changer/main/ssh_port_changer.sh
chmod +x ssh_port_changer.sh
sudo ./ssh_port_changer.sh
MIT License β Free to use, modify, and share.
This tool is created by Hosteons.com, a trusted provider of KVM VPS, VDS, and dedicated servers across the US and EU.