将文件上传到 sshd sftp 服务器时出错,出站消息太长

问题描述 投票:0回答:1

尝试从 linux sftp 客户端上传文件(>=500KB)到使用 apache sshd 实现的 sftp 服务器时,会抛出以下错误。

出站消息太长262197

同一服务器可与文件 zilla 一起使用文件,并且还可以使用此客户端将大文件上传到其他 sftp 服务器。

根据代码,如果输出缓冲区大于256kB,则会生成错误消息。

我发现了多个关于“收到的消息太长”消息的参考,但没有关于“出站消息太长”的参考。

我正在使用以下框架使用 mina-sshd 2.10.0 创建 sftp 服务器,如无法连接到 Apache MINA sshd 服务器中所述。

public class Main {
    public static void main(String[] args) {

        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.setPort(22);
        sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(Paths.get("hostkey.ser")));

        sshd.setShellFactory(new ProcessShellFactory("/bin/sh", "-i", "-l"));
        sshd.setCommandFactory(new ScpCommandFactory());
        sshd.setSubsystemFactories(Collections.singletonList(builder.build()));

        sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());

        try {
            System.err.println("Starting SSHD on port 22");
            sshd.start();
            Thread.sleep(Long.MAX_VALUE);
            System.err.println("Exiting after a very (very very) long time");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

我无法确定为什么它只发生在这个客户端-服务器对上。感谢对此的任何帮助。谢谢你。

sftp openssh sshd apache-sshd
1个回答
0
投票

您需要告诉 sshSever 密钥中使用的算法(即 RSA 、 DSA 、 ECDSA )。在您的代码中替换并添加以下内容:

AbstractGeneratorHostKeyProvider hostKeyProvider =
                    new SimpleGeneratorHostKeyProvider(new File("hostkey").toPath());

            hostKeyProvider.setAlgorithm("RSA");
            sshServer.setKeyPairProvider(hostKeyProvider);

这应该有效!

© www.soinside.com 2019 - 2024. All rights reserved.