sshd restart during inital server setup on cnetos7

Posted October 13, 2016 5.2k views
Linux BasicsCentOSLinux Commands


After I tried to add Public Key Authentication, then I added the pubic key to the new remote user following by changing the permitrootlogin to “NO” as this tutorial said :

when I tried to reload the ssh to apply the new setting, it doesn’t and I got this error :

Redirecting to /bin/systemctl restart  ssh.service
Failed to restart ssh.service: Unit ssh.service failed to load: No such file or directory.

I tried to restart it using these both commands

systemctl reload sshd
service ssh restart

but it didn’t get restarted. When I checked it’s status, I found that it’s active and running. so what’s the solution to solve that and restart it ?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

The command to restart the service should be:

service sshd restart

From the output you shared it looks like you may have been running service ssh restart which referred to a service “ssh” that could not be found.