How to install SSH server on CentOS / RHEL

Quick and simple tutorial on installation of SSH server on CentOS/RHEL

Installation

To install SSH server run following commands on your CentOS/RHEL install

su

After you entered your password, enter following command to install

dnf install openssh-server

Now we will start sshd deamon and set it to start after reboot

systemctl start sshd
systemctl enable sshd

We will now check status of ssh deamon, by entering:

systemctl status sshd

We will also add exception in firewall to enable incoming traffic (be careful on double dashes!)::

firewall-cmd --zone=public --permanent --add-service=ssh
firewall-cmd --reload

That is it, you now have working ssh server

Testing

I will test it by connecting from Windows 10 machine via SSH on Putty

Works.

If you need to make configurational changes, ssh config file is located in /etc/ssh/sshd_config

After you are done with changing sshd_config, you will need to reload ssh service by running:

Systemctl reload sshd

Uninstall

To uninstall SSH enter following commands:

chkconfig sshd off
service sshd stop
su
yum erase openssh-server

Check if ssh server is uninstalled by typing in:

systemctl status sshd