How to Enable SSH Service on Rocky Linux 8 or CentOS 8

In this article, we’ll show you how to enable SSH service on Rocky Linux 8 or CentOS 8. If a user wants to connect Rocky Linux from another machine via ssh then both client and remote server should have SSH installed and enabled.

Steps to Enable SSH Service on Rocky Linux 8 or CentOS 8

How to Enable SSH Service on Rocky Linux 8 or CentOS 8

Step 1: Verify Openssh-server package on Rocky Linux

Mostly the Openssh-server package is already installed, you can verify with the below command. 

rpm -qa | grep openssh-server

Enable SSH Service on Rocky Linux 8 or CentOS 8

Step 2: Command to install Openssh-server in Rocky Linux

sudo dnf install openssh-server

Enable SSH Service on Rocky Linux 8 or CentOS 8

Type Y, then press the ENTER KEY to proceed Openssh-server package installation on Rocky Linux.

Step 3: Enable ssh service on Rocky Linux

sudo systemctl enable sshd --now

Step 4: Verify SSH connection and Service status

Command to check ssh connection

ss -lt | grep ssh

Enable SSH Service on Rocky Linux 8 or CentOS 8

Command to check SSH service status 

systemctl status sshd

Enable SSH Service on Rocky Linux 8 or CentOS 8

Now, you’ll be able to connect Rocky Linux from another machine via ssh. 

Disable SSH access (If not required)

sudo systemctl disable sshd --now

As per security reasons, disable the ssh connection if it is not required.

Re-enable SSH access (If required)

sudo systemctl enable sshd --now

End of article. You have successfully enabled SSH service on Rocky Linux 8 or CentOS 8.

Configure Firewall:

If the system has a firewall enabled, you need to allow SSH traffic. You can use the following command to open the SSH port (default is 22):

sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload

Adjust SELinux (if needed):

If SELinux is enforcing, you might need to make adjustments. You can check the SELinux status using:

sestatus

If SELinux is enabled and in enforcing mode, you may need to update the SELinux policy to allow SSH:

sudo semanage port -a -t ssh_port_t -p tcp 22

Login to the Server:

You should now be able to connect to your Rocky Linux 8 or CentOS 8 server using SSH.

ssh username@your_server_ip

Replace username with your actual username and your_server_ip with the IP address or hostname of your server.

Remember to replace any placeholder values with your specific information. This guide should help you enable and configure the SSH service on Rocky Linux 8 or CentOS 8.

See also:

List of monitoring tools 

Linux Blogs

AWS Cloud Blogs

Database Blogs

DevOps Blogs

Interview Questions & Answers

Docker Blogs

Google Cloud Blogs