0

On a virtual rhel 7.4 I'm getting a weird error when trying to start the sshd service.

Failed to start openssh.service: Unit not found

In fact, I get the same error when trying anything on sshd - enable, status or stop

openssh picture

I did try to restart the instance but nothing seems to work.

  • can you start other services ? is it just ssh ? and is the package installed correctly ? (e.g. yum reinstall openssh) – olivierg Mar 24 '18 at 20:54
  • yes, I can start any other services and afaik the package is installed correctly as yum reinstall openssh runs without errors – Cat Hariss Mar 24 '18 at 21:16
  • 1
    I am pretty sure the service name is only "sshd" and not "openssh" – Tim Haegele Mar 24 '18 at 21:17
  • @TimHaegele systemctl enable sshd.service throws the same error – Cat Hariss Mar 24 '18 at 21:19
  • do you see the service using systemctl list-units --type service --all ? – olivierg Mar 24 '18 at 21:36
3

Before you can run the OpenSSH server, you must install it, but you haven't actually installed it. To fix the problem, install the OpenSSH server.

[root@localhost ~]# yum install openssh-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
Resolving Dependencies
--> Running transaction check
---> Package openssh-server.x86_64 0:7.4p1-16.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch      Version           Repository                  Size
================================================================================
Installing:
 openssh-server    x86_64    7.4p1-16.el7      rhel-7-server-beta-rpms    458 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 458 k
Installed size: 971 k
Is this ok [y/d/N]: y
Downloading packages:
openssh-server-7.4p1-16.el7.x86_64.rpm                     | 458 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : openssh-server-7.4p1-16.el7.x86_64                           1/1 
  Verifying  : openssh-server-7.4p1-16.el7.x86_64                           1/1 

Installed:
  openssh-server.x86_64 0:7.4p1-16.el7                                          

Complete!

The service is enabled by default, but if you do need to manage it, the systemd unit name is sshd.

[root@localhost ~]# systemctl start sshd
[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-03-24 17:37:23 EDT; 41s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1373 (sshd)
   CGroup: /system.slice/sshd.service
           └─1373 /usr/sbin/sshd -D

Mar 24 17:37:23 localhost.localdomain systemd[1]: Starting OpenSSH server dae...
Mar 24 17:37:23 localhost.localdomain sshd[1373]: Server listening on 0.0.0.0...
Mar 24 17:37:23 localhost.localdomain sshd[1373]: Server listening on :: port...
Mar 24 17:37:23 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
Hint: Some lines were ellipsized, use -l to show in full.
  • This is exactly what I first tried, just that when I start or status the sshd service I get the "Failed to start openssh.service: Unit not found" error – Cat Hariss Mar 25 '18 at 0:22
  • @CatHariss Again, you need to use the correct name. – Michael Hampton Mar 25 '18 at 0:26

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.