This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
将您的服务器配置为使用内部 sftp 服务器,将以下指令添加到
/etc/ssh/sshd_config
:这样,它就不会使用用户 shell 来启动 sftp 服务器程序。
Configure your server to use the internal sftp server adding the following directive to
/etc/ssh/sshd_config
:That way, it will not use the user shell to launch the sftp server program.
“收到的消息太长”意味着您的 SFTP 客户端从 SFTP 服务器收到了错误的数据。典型的原因是服务器上的 shell 启动脚本(.bashrc、.profile、.cshrc 等)正在生成一些输出,而您的 SFTP 客户端正在尝试将该输出解析为 SFTP 消息。您可以通过运行以下命令来检查这一点:
如果这会产生除“hello”之外的任何输出,则该输出可能会阻止 SFTP 或 SCP 正常工作。
正如萨尔瓦的回答一样,您可以通过将 SSH 服务器设置为使用 internal-sftp 用于 SFTP 会话。这可以避免为 SFTP 会话启动 shell。这对 SCP 或其他通过 ssh 运行的程序(如 git 或 rsync)没有帮助。
解决此问题的另一种方法是检查 shell 启动命令,找出产生输出的内容,并防止在非交互式 SSH 会话期间发生这种情况。一个技巧是在运行产生输出的命令之前测试 TTY:
"Received message too long" means that your SFTP client received bad data from the SFTP server. The typical reason is that the shell startup scripts on the server (.bashrc, .profile, .cshrc, etc.) are producing some output, and your SFTP client is trying to parse that output as an SFTP message. You can check this by running the command:
If this produces any output other than the "hello", then that output would probably prevent SFTP or SCP from working properly.
As in salva's answer, you can avoid this by setting the SSH server to use internal-sftp for SFTP sessions. This avoids launching your shell for SFTP sessions. This won't help with SCP or with other programs like git or rsync which run through ssh.
The other way to fix this is to go through your shell startup commands, figure out what is producing the output, and prevent that from happening during non-interactive SSH sessions. One tip is to test for a TTY before running commands which produce output:
它可以通过使用
internal-sftp
子系统来修复。编辑
/etc/ssh/sshd_config
并替换by
然后您需要使用以下命令重新启动 sshd 服务:
It can be fixed by using the
internal-sftp
subsystem.Edit
/etc/ssh/sshd_config
and replaceby
Then you need to restart
sshd
service with this command: