Change default SSH port on Fedora
I wanted to change my default SSH port to something else. Here are the commands I used:
- I modified the "Port" value in my SSH config:
vi /etc/ssh/sshd_config
It was commented out. I uncommented it and modified it.
- I installed "policycoreutils-python-utils" to gain access to the "semanage" command:
yum install policycoreutils-python-utils
- I ran "semanage" to add my preferred SSH port to the allowed SSH ports:
semanage port -a -t ssh_port_t -p tcp xxxx
- I checked to make sure it succeeded:
semanage port -l | grep ssh_port_t
- I added a firewall exception for my preferred SSH port:
firewall-cmd --permanent --service="ssh" --add-port "xxxx/tcp"
- I reloaded my firewall and SSH:
firewall-cmd --reload
systemctl reload sshd
- I rebooted to make sure it all still worked correctly on boot:
reboot