Error uploading files to sshd sftp server, Outbound message too long

309 views Asked by At

The following error is thrown while trying to upload files (>=500KB) from linux sftp client to an sftp server implemented with apache sshd.

Outbound message too long 262197

The same server works file with file zilla and also it is possible to upload large files to other sftp servers with this client.

As per the code , the error message is generated if the output buffer is larger than 256kB.

I found multiple references on "Received message too long" message, but not about "Outbound message too long".

I'm using following skeleton to create the sftp server with mina-sshd 2.10.0 as discussed in Unable to connect to Apache MINA sshd server.

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();
        }
    }
}

I was not able to identify why it happens with this client-server pair only. Appreciate any help on this. Thank you.

1

There are 1 answers

0
Deepak Sharma On

You need to tell your sshSever about the alogrithm used in the key(i.e. RSA , DSA , ECDSA). Replace and add the following in your code :

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

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

This should work!!