环境:
系统centos7.6
升级过程:
-
下载openssh最新版本8.0p1, make , make install
-
安装到/usr/local/openssh目录下
-
修改/usr/lib/systemd/system/sshd.service中,相应的可执行文件目录。
-
启动
systemctl daemon-reload
systemctl start sshd
问题:
问题出现了: 卡住了。
长时间没有返回。
等啊等,最后,返回了
查看状态:
systemctl status sshd
有这样的错误:
failed to start openssh server daemon code=exited, status=0/success
分析:
测试:
sshd -t
没问题。
命令行启动:
/usr/local/openssh/sbin/sshd
也没问题。
看来是systemd配置的问题。
看网上资料,
修改:
将
Type=nofify
改为:
Type=forking
并且去掉启动sshd的 -D参数
仍然不行。
sshd的参数 -D是不将sshd转为daemon运行。
结果
试了多种组合。终于找到正确配置:
(其实很简单,去掉Type或改为Type=simple就好了。原因未知)
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service
[Service]
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/local/openssh/sbin/sshd -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target