在CentOS系統上配置SFTP(Secure File Transfer Protocol)時,用戶可能會遇到一些常見問題。以下是一些常見問題及其解決方案:
/etc/ssh/sshd_config
文件,確保以下配置項正確:Subsystem sftp internal-sftp
Match User sftpuser
ChrootDirectory /data/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
然后重啟SSH服務:sudo systemctl restart sshd
/etc/ssh/sshd_config
中的以下參數:Subsystem sftp /usr/libexec/openssh/sftp-server
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding yes
保存配置文件并重啟SSH服務。/etc/ssh/sshd_config
中將 GSSAPIAuthentication
設置為 no
:GSSAPIAuthentication no
然后重啟SSH服務。firewall-cmd --zone=public --add-service=ssh --permanent
firewall-cmd --reload
setenforce 0
或者設置SELinux為permissive模式:SELINUX=permissive
/etc/ssh/sshd_config
中添加或取消注釋以下行:PasswordAuthentication yes
然后重啟SSH服務。sudo systemctl status sshd
啟動服務:sudo systemctl start sshd
chrootDirectory
指定)權限設置正確。例如,如果 chrootDirectory
設置為 /home/sftpuser
,則該目錄及其所有上級目錄的屬主和屬組都應該是root,并且權限設置為755。/etc/ssh/sshd_config
文件,確保 Subsystem sftp
設置為 internal-sftp
或指定的路徑。如果使用 chroot
,確保 chrootDirectory
指向的目錄存在且權限設置正確。通過以上步驟,可以逐步排查并解決CentOS系統中SFTP服務可能遇到的常見問題。如果問題仍然存在,建議查閱相關文檔或尋求專業幫助。