centos7 sftp设置后 ssh 启动失败 原因分析
大多数人 在 设置SFTP 使用时,会在 ../sshd_config中添加如下内容:
-------------------------------
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory /data
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
------------------------------
启动时 报如下错误:
-- Unit sshd.service has begun starting up.
2月 07 16:49:31 soc26 sshd[2074]: /etc/ssh/sshd_config line 147: Directive 'Subsystem' is not allowed within a Match block
2月 07 16:49:31 soc26 systemd[1]: sshd.service: control process exited, code=exited status=255
2月 07 16:49:31 soc26 systemd[1]: Failed to start OpenSSH server daemon.
-- Subject: Unit sshd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sshd.service has failed.
--
-- The result is failed.
2月 07 16:49:31 soc26 systemd[1]: Unit sshd.service entered failed state.
2月 07 16:49:31 soc26 systemd[1]: sshd.service failed.
2月 07 16:49:31 soc26 polkitd[1295]: Unregistered Authentication Agent for unix-process:2067:361270 (system bus name :1.27, object path /org/freedesktop/PolicyKit1/AuthenticationAgent,
2月 07 16:49:46 soc26 polkitd[1295]: Registered Authentication Agent for unix-process:2084:362757 (system bus name :1.28 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /or
2月 07 16:49:46 soc26 systemd[1]: Cannot add dependency job for unit microcode.service, ignoring: Unit is not loaded properly: Invalid argument.
2月 07 16:49:46 soc26 systemd[1]: Starting OpenSSH server daemon...
-- Subject: Unit sshd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sshd.service has begun starting up.
2月 07 16:49:46 soc26 sshd[2090]: /etc/ssh/sshd_config line 153: Directive 'UseDNS' is not allowed within a Match block
2月 07 16:49:46 soc26 systemd[1]: sshd.service: control process exited, code=exited status=255
2月 07 16:49:46 soc26 systemd[1]: Failed to start OpenSSH server daemon.
-- Subject: Unit sshd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sshd.service has failed.
--
-- The result is failed.
2月 07 16:49:46 soc26 systemd[1]: Unit sshd.service entered failed state.
2月 07 16:49:46 soc26 systemd[1]: sshd.service failed.
2月 07 16:49:46 soc26 polkitd[1295]: Unregistered Authentication Agent for unix-process:2084:362757 (system bus name :1.28, object path /org/freedesktop/PolicyKit1/AuthenticationAgent,
排除其他可能的原因,可以尝试如下:
将
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory /data
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
放在
UseDNS no
之后
就解决了。