大多數人 在 設定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
之後
就解決了。