以下是Linux SFTP安全設置指南:
sudo apt-get install openssh-server
,CentOS/RHEL系統用sudo yum install openssh-server
。/etc/ssh/sshd_config
中指定的SFTP用戶組,如sftpusers
,再創建用戶并加入該組,設置用戶主目錄及權限,確保主目錄屬主為root,權限為755。/etc/ssh/sshd_config
,啟用SFTP子系統,如Subsystem sftp internal - sftp
;限制用戶組,如Match Group sftpusers
;設置ChrootDirectory
為用戶主目錄;禁止X11轉發和TCP轉發;還可設置ForceCommand internal - sftp
等。sudo systemctl restart sshd
重啟服務使設置生效。