在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服务可能遇到的常见问题。如果问题仍然存在,建议查阅相关文档或寻求专业帮助。