CentOS SFTP配置中常見錯誤及解決方法如下:
sudo systemctl status sshd
,未啟動則執行sudo systemctl start sshd
并設置開機自啟sudo systemctl enable sshd
。sudo firewall-cmd --permanent --add-service=ssh
,然后sudo firewall-cmd --reload
。/etc/ssh/sshd_config
中Subsystem sftp
路徑是否正確(通常為internal-sftp
或/usr/libexec/openssh/sftp-server
),并確保ChrootDirectory
等指令配置無誤,修改后重啟服務。ChrootDirectory
)需為root:root
且權限為755,用戶主目錄權限通常為755,上傳目錄可設為775,確保用戶對目標目錄有寫入權限。sudo setenforce 0
,若問題解決則調整策略,如設置SELINUX=permissive
或通過semanage
修改文件上下文。sftpusers
),公鑰認證需將公鑰放入~/.ssh/authorized_keys
并設置權限為600。ping
和telnet
),確認SSH服務監聽端口正確,可在配置中添加TCPKeepAlive yes
等參數優化連接。