Interview Prep/Linux/Networking, SSH and remote access

You must open SSH on a non-standard port 2222 on a RHEL server with SELinux enforcing. What steps are needed?

IntermediateScenarioNetworking, SSH and remote access
Answer

Situation read → sshd config, SELinux port label and firewall all need changing.

What I'd do →

sudo semanage port -a -t ssh_port_t -p tcp 2222
echo 'Port 2222' | sudo tee /etc/ssh/sshd_config.d/20-port.conf
sudo firewall-cmd --permanent --add-port=2222/tcp && sudo firewall-cmd --reload
sudo sshd -t && sudo systemctl restart sshd
ss -tlnp | grep 2222

Why → SELinux only lets sshd bind to ports labelled ssh_port_t; without it, sshd fails to start.

Interview tip → Say a non-standard port reduces log noise but isn't real security.

All Linux questions Roadmap: Linux

More on Networking, SSH and remote access