记一次sftp登陆失败

使用FlashFXP登陆sftp时,出现了连接失败的情况,log提示如下

[10:09:27] [R] 正在连接到 192.168.10.50 -> IP=192.168.10.50 PORT=22
[10:09:27] [R] 已连接到 192.168.10.50
[10:09:27] [R] 主机密钥算法 , size 192 bits.
[10:09:27] [R] 指纹 (SHA256): 
[10:09:27] [R] 密钥交换:  会话加密:,MAC: <implicit>,压缩: none.
[10:09:27] [R] Auth Type: Password
[10:09:27] [R] 身份验证成功
[10:09:27] [R] SSH 连接打开
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] [info] subsystem request for sftp failed, subsystem not found.
[10:09:28] [R] [execute] /usr/lib/openssh/sftp-server
[10:09:28] [R] [execute] /usr/lib/sftp-server
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] [execute] /usr/local/lib/sftp-server
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] [execute] /usr/libexec/sftp-server
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] [execute] sftp-server
[10:09:28] [R] SSH 错误: 101 Invalid Packet
[10:09:28] [R] 连接失败 (Unable to access SFTP sub-system, operation failed.)

根据错误提示,表示有无效的数据包返回回来。我们使用的是centos7作为sftp服务器,此时,登陆centos7,查看/var/log/secure文件,/var/log/secure 一般用来记录安全相关的信息,记录最多的是哪些用户登录服务器的相关日志。

Oct  2 10:58:38 localhost sshd[32739]: pam_unix(sshd:session): session closed for user root
Oct  2 10:58:41 localhost sshd[2659]: reprocess config line 43: Deprecated option RSAAuthentication
Oct  2 10:58:41 localhost sshd[2659]: Accepted password for root from 192.168.10.2 port 56800 ssh2
Oct  2 10:58:41 localhost sshd[2659]: pam_unix(sshd:session): session opened for user root by (uid=0)

实际登陆是成功的,那么为什么FlashFXP会无法获取到数据呢?

我们知道,sftp在linux中,其实就是借助ssh登陆操作系统,然后使用一系列的命令去上传跟下载文件,而在linux下,用户登陆过程中,系统会自动执行一些配置文件,如果此时系统输出了一些内容,那么就会导致flashfxp执行接下来指令过程中获取到不匹配的输出。所以导致获取sftp文件目录失败,进而导致登陆失败。

首先,我们检查sftp登陆的系统中,使用su - sftpname

首先检查下输出是否有问题,正常来讲,登陆后,shell是不会输出任何内容的。

但是因为我们上次修改过~./bashrc、~./bash_profile、/etc/bashrc、/etc/profile中的某个文件,导致登录时,进程输出了一些内容出来。此时我们将原本测试的输出内容删除,然后再使用flashFXP进行登陆,成功!
用户登陆执行脚本/配置文件顺序
 /etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout

发布了24 篇原创文章 · 获赞 2 · 访问量 8203

猜你喜欢

转载自blog.csdn.net/Dragonlongbo/article/details/102364960