环境
操作系统:CentOS 7
问题
重启ssh服务,启动报错:Failed to restart ssh.service: Unit not found.
操作步骤
1. 编辑sshd_config文件
vim /etc/ssh/sshd_config
2. 重启ssh服务
service ssh restart
3. 启动失败,报错
Redirecting to /bin/systemctl restart ssh.service Failed to restart ssh.service: Unit not found.
解决方案
从 CentOS 7.x 开始,CentOS 开始使用 systemd 服务来代替 daemon,原来管理系统启动和管理系统服务的相关命令全部由 systemctl命令来代替。
# CentOS 7 systemctl restart sshd # CentOS 6 service restart sshd