Change sshd port on RHEL / CentOS / Fedora with selinux context

You’d like to change the sshd port on CentOS, RHEL or Fedora.

Let’s assume you’d like to change it from port 22 (default) to port 22220 and have selinux enabled.
Also your remote hostname is example.com .
Let’s also assume semanage is installed. If not, the package name start with policycoreutils-python.
yum install policycoreutils-python
or
dnf install policycoreutils-python
dnf install policycoreutils-python-utils

If unsure press tab. And if you don’t know what tab is, what are you doing here anyway?

And we’re done

You can now use

to log into your server

If you don’t want to add a config, you can use

to do it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.