4

I am attempting to use the JSch class (Java Secure Channel; jsch-0.1.50.jar) to connect to an SFTP server and send a file from within a ColdFusion (9.0.2) application (which runs atop Java 1.7.0_15). The basic code in question is:

jsch = classLoader.create("com.jcraft.jsch.JSch").init(); // ColdFusion-specific to load the jar
jschSession = jsch.getSession("myusername", "ftp.example.com", 22);
jschSession.setConfig("StrictHostKeyChecking", "no");
jschSession.setTimeout(60000);
jschSession.setPassword("mypassword");
jschSession.connect();

Upon connection to a Serv-U SFTP server it is giving me the following error on the Serv-U side immediately after the connection opens:

SSH Protocol Error: packet size exceeds maximum allowed.

Serv-U then closes the session, at which point JSch throws the exception:

Session.connect: java.io.IOException: End of IO Stream Read

I am new to the JSch class, and it's possible I'm missing something obvious, but I am at a loss as to where the error may lie. Connecting to the same SFTP server from the same origin with WinSCP gives no errors. Any tips on what the code is doing wrong or where to turn next for troubleshooting?

Justin Scott
  • 865
  • 4
  • 10

1 Answers1

0
SSH Protocol Error: packet size exceeds maximum allowed

This means that the local client received some data from the remote server which wasn't properly formatted as an SFTP protocol message. The usual reason is that the server sent some kind of plain text message through the SSH connection. There are few things that might be going on:

  1. Your .bashrc, .bash_profile, or similar shell configuration file on the server is set to print some message.
  2. The server is poorly configured, and it's sending some kind of greeting.
  3. The server is sending some kind of error message.

If you have access to the ssh command-line utility, you can use that to see what the server is sending. Run something like this:

$ ssh myusername@ftp.example.com -s sftp

This will open a plain SSH session to the remote server and request the SFTP subsystem, which is the same thing an SFTP client would do. If the server starts SFTP properly, you won't see any output from this command--it'll just wait until you kill it. If you see any text from the remote server, that is the problem. You'll need to figure out why the server is sending that text and prevent it.

Kenster
  • 23,465
  • 21
  • 80
  • 106
  • Thanks for trying to answer this old question. I ended up using a different solution entirely way back when, but in this instance the error was showing up on the server side, not on the client side. I was able to connect to the server just fine with any other SCP client which ruled out an issues on the server side, it was only this client library that would throw something across the line it wasn't supposed to, so I gave up and scripted WinSCP instead. – Justin Scott Dec 03 '17 at 01:09