保障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
)使更改生效。