Filezilla或腻子:我有“访问授予”,其次是“服务器意外closuresnetworking连接”。 如何解决问题?

以下是Filezilladebugging跟踪的摘录:

Offered public key from "(...)" Offer of public key accepted, trying to authenticate using it. Access granted Server unexpectedly closed network connection 

我注意到在debugging模式下putty的行为是相同的,访问被授予,然后“服务器意外closuresnetworking连接”。

从/ etc / ssh / sshd_config中删除以下行时:

 Match User user1 ChrootDirectory /home/user1 AllowTCPForwarding no X11Forwarding no ForceCommand /usr/lib/openssh/sftp-server 

然后Filezilla可以连接但不是PuTTY。 这是好的,因为我只是针对FTP,但是那么user1可以访问远远多于所需的主目录,这是不好的。

任何想法如何解决这个问题? 有没有在服务器端看日志?

PS:我认为这与问题没有任何关系,但是validation是基于关键的(因为它出现在痕迹中)。

更新:感谢弗雷德·克劳森很好的build议,我看了一下/ var / log / secure并修复了“致命:所有权或者chroot目录组件的模式”问题。 但它仍然无法正常工作。 这里是/ var / log / secure的内容

 Accepted publickey for user1 from ***.***.***.*** port 56432 ssh2 pam_unix(sshd:session): session opened for user user1 by (uid=0) subsystem request for sftp by user user1 pam_unix(sshd:session): session closed for user user1 

从Filzilladebugging,我发现这个interesrting错误:

 Event Log: Started a shell/command Incoming packet #0xc, type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) 00000000 00 00 01 00 00 00 00 26 2f 62 69 6e 2f 62 61 73 .......&/bin/bas 00000010 68 3a 20 4e 6f 20 73 75 63 68 20 66 69 6c 65 20 h: No such file 00000020 6f 72 20 64 69 72 65 63 74 6f 72 79 0d 0a or directory.. 

看着它…

这是好的,因为我只是针对FTP,但是那么user1可以访问远远多于所需的主目录,这是不好的。

除了FTP和SFTP都可以用于传输文件之外,FTP和SFTP之间没有任何关系。

无论如何,SFTPlogin我在sshd_config使用:

 Subsystem sftp internal-sftp -f AUTH -l INFO Match Group sftp ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no AuthorizedKeysFile %h/authorized_keys Match 

可以sftp的用户在sftp组中。 确保你给他们/sbin/nologinshell。 他们将从OpenSSH获得他们所需要的。

最后,如果主目录不存在,我认为你也将被断开连接。 以及用户是否无权访问主目录。 家庭的权利应该是700 ,用户和组也应该是用户的用户名和组名。 在你的例子中:

1049327 drwx------. 2 user1 user1 4,0K oct 8 2013 user1

这一切都涉及到CentOS,我不知道这是否在另一个小礼服工作。

你混淆了chroot和putty和filezilla的不同之处。 putty需要远程shell或“假”shell,一些命令。 filezilla希望sftp。

所以你必须决定。 如果你只需要sftp,就不能使用腻子。 如果你想使用sftp,请阅读man sshd,你可能想要放在那里internal-sftp,因为它不需要完整的chroot设置。 如果你把sftp-server的完整path,你必须把chroot所有库和其他强制性文件。

Filezilla输出显示你清楚你没有正确configurationchroot。