参考:http://blog.csdn.net/mengjiangtao/article/details/24195523
sudo service ssh start
报错:
Failed to start ssh.service: Unit ssh.service not found.
添加ssh.service
sudo systemctl enable ssh.service
报错:
ssh.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable ssh
insserv: warning: script 'ssh' missing LSB tags and overrides
update-rc.d: error: ssh Default-Start contains no runlevels, aborting.
原因:/etc/init.d/ssh没有LSB tags。参考其他文件,格式如下:
#!/bin/sh
### BEGIN INIT INFO
# Provides: skeleton
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $portmap
# Should-Stop: $portmap
# X-Start-Before: nis
# X-Stop-After: nis
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
重新执行:
sudo systemctl enable ssh.service
ssh.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable ssh
sudo systemctl start ssh.service
sudo systemctl status ssh.service
● ssh.service - LSB: sshd start/stop
Loaded: loaded (/etc/init.d/ssh; bad; vendor preset: enabled)
Active: active (running) since 二 2018-03-20 11:06:41 CST; 11s ago
Docs: man:systemd-sysv-generator(8)
Process: 8576 ExecStart=/etc/init.d/ssh start (code=exited, status=0/SUCCESS)
Tasks: 1
Memory: 2.4M
CPU: 37ms
CGroup: /system.slice/ssh.service
└─8598 /usr/local/openssh-7.6p1/sbin/sshd
3月 20 11:06:41 gg systemd[1]: Starting LSB: sshd start/stop...
3月 20 11:06:41 gg ssh[8576]: unknown key type rsa1
3月 20 11:06:41 gg ssh[8576]: starting /usr/local/openssh-7.6p1/sbin/sshd... done.
3月 20 11:06:41 gg systemd[1]: Started LSB: sshd start/stop.
3月 20 11:06:41 gg sshd[8598]: Server listening on 0.0.0.0 port 22.
3月 20 11:06:41 gg sshd[8598]: Server listening on :: port 22.