保障CentOS SFTP配置安全可從以下方面入手:
/etc/ssh/sshd_config
,添加Match User root
并設置ForceCommand internal-sftp
,禁止root用戶通過SFTP登錄。sftpusers
),將用戶加入該組,限制其僅能訪問主目錄。ChrootDirectory
將用戶限制在主目錄,配合ForceCommand internal-sftp
禁止執行其他命令。PasswordAuthentication no
),使用SSH密鑰對驗證,提升安全性。AllowTcpForwarding
和X11Forwarding
。Subsystem sftp internal-sftp -l verbose
),定期審計異?;顒?。配置后需重啟SSH服務(systemctl restart sshd
)使更改生效。