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.

Spread the love

Leave a Reply

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