Once you have installed the Fedora system on your VirtualBox or hardware, there may be a possibility you will access your system remotely through the SSH service, and when you try to access it, you may find the error “ssh: connect to host 192.168.40.120 port 22: No route to host.”
And when you try to check the status of the SSH service in your Fedora, you may get another error: “Unit ssh.service could not be found.”
If you are also facing a similar kind of issue or you want to install an OpenSSH server on Fedora, then this article can be helpful to fix the above issue.
Step 1: Install an OpenSSH server on Fedora 36
As far as I know, you will find the OpenSSH server preinstalled on your Fedora machine. To get a better idea of whether it is available or not, run the below command, which will print the OpenSSH server version.
$ rpm -iq openssh-server
If you get the output with the OpenSSH version, then you are good to go ahead and enable the SSH service from the next section.
And for those who get the output “OpenSSH version is not installed,” type the below code to start the installation.
$ sudo dnf install openssh-server
Once the installation is complete, move to the next part to enable the SSH service.
Step 2: Enable the OpenSSH server on Fedora 36
The very first step to resolving the above error is to enable the SSH service on your Fedora system, and you will probably get the above error when you try to start the SSH service.
This error is common among newcomers who have recently switched from Ubuntu to Fedora. In Ubuntu, when you invoke the below command to start or check the status on your terminal, it gets accepted because the ssh unit service is available and it is mapped to the default sshd.unit service.
$ sudo systemctl status ssh
$ sudo systemctl start ssh
And this is not the same case with Fedora. You have to invoke the proper command to enable, start, or stop the SSH service.
To check the SSH service status in Fedora, run the below command:
$ sudo systemctl status sshd
The output of the above command cleared out the error and showed the current status of the OpenSSH service, which is “inactive”.
Now you can change the status to “active”. Before that, enable the sshd service to automatically restart the SSH service after every boot.
$ sudo systemctl enable sshd
Step 3: Start the OpenSSH server on Fedora 36
Once you are done with the above step, you can start the SSH service to connect with the remote host system.
Run the below code to start the SSH service to connect with the remote system.
$ sudo systemctl start sshd
After that, once again, check the current status of the SSH service.
$ sudo systemctl status sshd
Try to connect your Fedora machine
Once the above changes have been successfully implemented, you can try to connect back to your Fedora system from a remote system.
$ ssh [email protected]
If the firewall is implemented on your system, then run the following line to your Fedora system to accept incoming SSH connections through the firewall connection, and then try to connect to your Fedora system.
# firewall-cmd --zone=public --permanent --add-service=ssh
# firewall-cmd --reload
That’s all to install and start the SSH server in Fedora. You can follow these same steps in other RHEL-based distributions.
In this particular article, you have learned the following:
- How to install an SSH server
- How to start an SSH server in Fedora
- How to check SSH service status in Fedora.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.