sshsftpjschssh2-sftp

sftp fails with 'message too long' error


My java program uses ssh/sftp for transferring files into linux machines (obviously...), and my library for doing so is JSch (though it's not to blame).

Now, some of these linux machines, have shell login startup scripts, which tragically causes the ssh/sftp connection to fail, with the following message:

Received message too long 1349281116

After briefly reading about it, it's clearly a known ssh design issue (not a bug - see here). And all suggested solutions are on ssh-server side (i.e. disable scripts which output messages during shell login).

My question - is there on option to avoid this issue on client side?


Solution

  • Here's a quick-n'-dirty solution, but it seems to work - also on binary files. All credits goes to uvgroovy.

    Given file 'some-file.txt', just do:

    cat some-file.txt | ssh root:1.1.1.1 /bin/bash -c "cat > /root/some-new-file.txt"
    

    Still, if anyone know a sftp/scp built-in way to do so on client side, it'll be great.