I was trying to retrieve a file from SFTP server - while connecting to this SFTP works with FileZilla - SFTP method.
For JSch I have tried this code using JSch
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 );
Though I got this error:
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)
With StandardFileSystemManager
I'm also having the same error:
SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, connectionTimeout);
SftpFileSystemConfigBuilder.getInstance().setIdentityInfo(opts);
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
StandardFileSystemManager fsManager = new StandardFileSystemManager();
fsManager.init();
Got me this error:
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
I have tried other solution offered in these links which didn't solve it:
SFTP connector throwing error while giving encrytped passwords in properties file
com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 2 protocol error: rcvd type 90
java jsch SSH_MSG_DISCONNECT Failed to read binary packet data
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.
When I was working with FileZilla this is the log I was seeing in console:
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->server encryption
Trace: Initialised HMAC-SHA1 client->server MAC algorithm
Trace: Initialised AES-256 CBC server->client encryption
Trace: Initialised HMAC-SHA1 server->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)
What can I do to solve this error?
Attaching also the log from JSch
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->client aes128-cbc hmac-md5 none
INFO: kex: client->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
This config was missing and with it, I was able to connect
Properties config = new Properties();
config.put("kex","diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1");
and log:
INFO: kex: server->client aes128-cbc hmac-md5 none
INFO: kex: client->server aes128-cbc hmac-md5 none
INFO: SSH_MSG_KEX_DH_GEX_REQUEST(1024<2048<2048) sent
INFO: expecting SSH_MSG_KEX_DH_GEX_GROUP
INFO: SSH_MSG_KEX_DH_GEX_INIT sent
INFO: expecting SSH_MSG_KEX_DH_GEX_REPLY
INFO: ssh_rsa_verify: signature true
WARN: Permanently added '192.192.com' (RSA) to the list of known hosts.
INFO: SSH_MSG_NEWKEYS sent
INFO: SSH_MSG_NEWKEYS received
INFO: SSH_MSG_SERVICE_REQUEST sent
INFO: SSH_MSG_SERVICE_ACCEPT received
INFO: Authentications that can continue: password
INFO: Next authentication method: password
INFO: Authentication succeeded (password).