连接失败
systemctl status sshd
),未启动则执行systemctl start sshd
。firewall-cmd --add-service=sftp --permanent
),并重载防火墙。ping
和telnet
测试服务器IP及端口是否可达。登录失败
/etc/ssh/sshd_config
中PasswordAuthentication
是否启用。root
拥有,权限设为755,且用户需属于sftp
组(通过usermod -G sftpusers username
添加)。ssh_home_t
(semanage fcontext -a -t ssh_home_t "/home/username(/.*)?"
),并执行restorecon -Rv /home/username
。无法访问目录
chown username:username /home/username/upload
)。ChrootDirectory
,需确保该目录权限为755,且用户无法跳出该目录(通过ForceCommand internal-sftp
限制)。文件上传/下载失败
df -h
检查磁盘空间,清理或扩容后重试。mount | grep "ro"
),若为只读需修改挂载选项。配置文件语法错误
/etc/ssh/sshd_config
中Subsystem sftp
路径是否正确(通常为internal-sftp
或/usr/libexec/openssh/sftp-server
),修改后需重启SSH服务。sshd -t
测试配置文件语法,确保无错误。日志异常
/var/log/secure
或journalctl -u sshd
,定位错误信息(如“Permission denied”“Connection refused”),针对性解决。GSSAPIAuthentication no
)并重启SSH服务。ifconfig eth0 mtu 1400
)。/etc/ssh/sshd_config
中设置PermitRootLogin no
,避免直接以root用户通过SFTP操作。Match Group
限制特定用户组仅能访问其家目录,禁止执行其他命令。参考来源: