title: SFTP connection error with JSch: SSH_MSG_DISCONNECT: 11 Internal server error
body: <p>I was trying to retrieve a file from SFTP server - while connecting to this SFTP works with FileZilla - SFTP method.</p>
  
  <p>For JSch I have tried this code using JSch </p>
  
  <pre><code>JSch jsch = new JSch();
  Properties config = new Properties();
  config.put("StrictHostKeyChecking", "no");
  config.put("PreferredAuthentications", "password");
  Session session = jsch.getSession( "super_robot", "192.192.192.com", 6222 );
  session.setConfig(config );
  session.setPassword( "a1234!X@" );
  session.connect( 30000 );
  </code></pre>
  
  <p>Though I got this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Caused by: com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 Internal server error. 
      at com.jcraft.jsch.Session.read(Session.java:1004)
      at com.jcraft.jsch.Session.connect(Session.java:323)
  </code></pre>
  
  <p>With <code>StandardFileSystemManager</code> I'm also having the same error:</p>
  
  <pre><code>SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, connectionTimeout);
  SftpFileSystemConfigBuilder.getInstance().setIdentityInfo(opts);
  
  SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
  StandardFileSystemManager fsManager = new StandardFileSystemManager();
  fsManager.init();
  </code></pre>
  
  <p>Got me this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "digital.crossix.com".
      at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:147)
      at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:79)
      ... 40 more
  Caused by: com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 Internal server error. 
      at com.jcraft.jsch.Session.read(Session.java:1004)
      at com.jcraft.jsch.Session.connect(Session.java:323)
      at com.jcraft.jsch.Session.connect(Session.java:183)
      at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:145)
      ... 41 more
  </code></pre>
  
  <p>I have tried other solution offered in these links which didn't solve it:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/43070939/sftp-connector-throwing-error-while-giving-encrytped-passwords-in-properties-fil">SFTP connector throwing error while giving encrytped passwords in properties file</a> </p></li>
  <li><p><a href="https://stackoverflow.com/questions/44653214/com-jcraft-jsch-jschexception-ssh-msg-disconnect-2-protocol-error-rcvd-type-9">com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 2 protocol error: rcvd type 90</a> </p></li>
  <li><p><a href="https://stackoverflow.com/questions/34351298/com-jcraft-jsch-jschexception-ssh-msg-disconnect-11-no-appropriate-prime-betwe">com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 No appropriate prime between 1024 and 1024 is available. en</a> </p></li>
  <li><p><a href="https://stackoverflow.com/questions/32307009/java-jsch-ssh-msg-disconnect-failed-to-read-binary-packet-data">java jsch SSH_MSG_DISCONNECT Failed to read binary packet data</a></p></li>
  </ul>
  
  <p>Note that none of these errors is exactly the same as the error I'm facing - they are a bit similar.
  Didn't found someone that had the exact error I'm facing.</p>
  
  <p>When I was working with FileZilla this is the log I was seeing in console:</p>
  
  <pre class="lang-none prettyprint-override"><code>Status: Connecting to 192.192.com:6222...
  Trace:  CControlSocket::SendNextCommand()
  Trace:  CSftpConnectOpData::Send() in state 0
  Trace:  Going to execute C:\Program Files\FileZilla FTP Client\fzsftp.exe
  Response:   fzSftp started, protocol_version=8
  Trace:  CSftpConnectOpData::ParseResponse() in state 0
  Trace:  CControlSocket::SendNextCommand()
  Trace:  CSftpConnectOpData::Send() in state 3
  Command:    open "super_robot@192.192.com" 6222
  Trace:  Connecting to 192.192.194 port 6222
  Trace:  We claim version: SSH-2.0-FileZilla_3.30.0
  Trace:  Server version: SSH-2.0-NuaneSSH_0.8.1.0
  Trace:  Using SSH protocol version 2
  Trace:  Doing Diffie-Hellman group exchange
  Trace:  Doing Diffie-Hellman key exchange with hash SHA-1
  Trace:  Server also has ssh-dss host key, but we don't know it
  Trace:  Host key fingerprint is:
  Trace:  ssh-rsa 1024 ------------------------------------
  Command:    Trust new Hostkey: Once
  Trace:  Initialised AES-256 CBC client-&gt;server encryption
  Trace:  Initialised HMAC-SHA1 client-&gt;server MAC algorithm
  Trace:  Initialised AES-256 CBC server-&gt;client encryption
  Trace:  Initialised HMAC-SHA1 server-&gt;client MAC algorithm
  Trace:  Attempting keyboard-interactive authentication
  Trace:  Using keyboard-interactive authentication. inst_len: 0, num_prompts: 1
  Command:    Pass: ********
  Trace:  Access granted
  Trace:  Opening session as main channel
  Trace:  Opened main channel
  Trace:  Started a shell/command
  Status: Connected to 192.192.com
  Trace:  CSftpConnectOpData::ParseResponse() in state 3
  Trace:  CControlSocket::ResetOperation(0)
  Trace:  CSftpConnectOpData::Reset(0) in state 3
  Trace:  CFileZillaEnginePrivate::ResetOperation(0)
  Status: Retrieving directory listing...
  Trace:  CControlSocket::SendNextCommand()
  Trace:  CSftpListOpData::Send() in state 0
  Trace:  CSftpChangeDirOpData::Send() in state 0
  Trace:  CSftpChangeDirOpData::Send() in state 1
  Command:    pwd
  Response:   Current directory is: "/"
  Trace:  CSftpChangeDirOpData::ParseResponse() in state 1
  Trace:  CControlSocket::ResetOperation(0)
  Trace:  CControlSocket::ParseSubcommandResult(0)
  Trace:  CSftpListOpData::SubcommandResult() in state 1
  Trace:  CControlSocket::SendNextCommand()
  Trace:  CSftpListOpData::Send() in state 2
  Trace:  CSftpListOpData::Send() in state 3
  Command:    ls
  Status: Listing directory /
  Trace:  CSftpListOpData::ParseResponse() in state 3
  Trace:  CControlSocket::ResetOperation(0)
  Status: Directory listing of "/" successful
  Trace:  CFileZillaEnginePrivate::ResetOperation(0)
  </code></pre>
  
  <p>What can I do to solve this error?</p>
  
  <p>Attaching also the log from JSch</p>
  
  <pre class="lang-none prettyprint-override"><code>INFO: Connection established
  INFO: Remote version string: SSH-2.0-NuaneSSH_0.8.1.0
  INFO: Local version string: SSH-2.0-JSCH-0.1.54
  INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
  INFO: aes256-ctr is not available.
  INFO: aes192-ctr is not available.
  INFO: aes256-cbc is not available.
  INFO: aes192-cbc is not available.
  INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
  INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
  INFO: SSH_MSG_KEXINIT sent
  INFO: SSH_MSG_KEXINIT received
  INFO: kex: server: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
  INFO: kex: server: ssh-rsa,ssh-dss
  INFO: kex: server: aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
  INFO: kex: server: aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
  INFO: kex: server: hmac-sha1,hmac-md5
  INFO: kex: server: hmac-sha1,hmac-md5
  
  INFO: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
  INFO: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
  INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
  INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
  INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
  INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
  
  INFO: kex: server-&gt;client aes128-cbc hmac-md5 none
  INFO: kex: client-&gt;server aes128-cbc hmac-md5 none
  INFO: SSH_MSG_KEXDH_INIT sent
  INFO: expecting SSH_MSG_KEXDH_REPLY
  INFO: Disconnecting from 192.192.com port 6222
  
  Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65)
  Caused by: com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 Internal server error. 
      at com.jcraft.jsch.Session.read(Session.java:1004)
      at com.jcraft.jsch.Session.connect(Session.java:323)
      at com.xxxxxxx.yyyy.service.SFTPTest.main(SFTPProviderTest.java:50)
      ... 5 more
  </code></pre>