当前位置: 首页 > 知识库问答 >
问题:

SFTP与JSch的连接错误:SSH\u MSG\u DISCONNECT:11内部服务器错误

蒋健
2023-03-14

我试图检索一个文件从SFTP服务器-而连接到这个SFTP工作与FileZilla-SFTP方法。

对于JSch,我使用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 );

虽然我有这个错误:

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)

使用StandardFileSystemManager时,我也遇到了同样的错误:

SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, connectionTimeout);
SftpFileSystemConfigBuilder.getInstance().setIdentityInfo(opts);

SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
StandardFileSystemManager fsManager = new StandardFileSystemManager();
fsManager.init();

给我这个错误:

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

我已经尝试了这些链接中提供的其他解决方案,但没有解决它:

>

通用域名格式。jcraft。jsch。JSCHEException:SSH\u MSG\u DISCONNECT:2协议错误:rcvd类型90

com.jcraft.jsch.JSchExcture:SSH_MSG_DISCONNECT: 11 1024和1024之间没有适当的素数可用。en

java jsch SSH_MSG_DISCONNECT无法读取二进制数据包数据

请注意,这些错误都与我面临的错误不完全相同-它们有点相似。没有找到和我面临的错误完全一样的人。

当我使用FileZilla时,这是我在控制台中看到的日志:

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)

如何解决此错误?

还附加来自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

共有2个答案

史飞尘
2023-03-14

这个配置丢失了,有了它,我就可以连接了

Properties config = new Properties();
config.put("kex","diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1");

和日志:

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).
荣俊
2023-03-14

似乎是服务器上的错误或问题。检查服务器端日志文件。

不过请注意,FileZilla使用“AES-256 CBC”成功连接。您的JSch代码仅使用"AES-128 CBC",因为"AES-256 CBC"不可用。

尝试安装JCE以启用“AES-256 CBC”。参见JSch算法协商失败。

 类似资料:
  • 我是新的角度6。我用spring boot开发了一个post服务,当我通过postman测试它时,它工作得很好,但当我用web浏览器测试它时,它给了我这个错误: HttpErrorResponse ;{headers:HttpHeaders,status:500,statusText:“ok”,URL:“http://localhost:8080/api/test/ordermiss”,ok:fa

  • 我用wordpress和woocommerce(www.jescesole.eu)建立了一个网站。由于该网站在德国销售,我不得不在最近几天安装一个附加插件,woocommerce germanized(与polylang一起,以德语和意大利语查看内容),我升级了wp和所有插件,但当客户提交订单时,会出现一条内部服务器错误消息。我阅读了服务器错误日志,并报告了一条很长的错误消息: 周四,13四月20

  • 问题内容: 我正在尝试为这个工作中的项目学习AJAX。我有一个网站加载病人正在服用的药物。 我递归调用此AJAX函数,以便它将附加一个包含单种药物和7天历史记录的新表。我在使代码在FF和IE中执行时遇到问题。在chrome中效果很好。我有显示xmlhttp.status的警报,这是我得到的: xmlhttp.status == 500(内部服务器错误)。 我注释掉了所有递归,因此将其范围缩小到了这

  • 我收到以下错误 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请联系服务器管理员,webmaster@strivemedicare.in并告知他们错误发生的时间,以及可能导致错误的任何行为。 有关此错误的详细信息,请参阅服务器错误日志。 此外,尝试使用错误文档处理请求时遇到 500 内部服务器错误错误。

  • 我的laravel项目通过Commission在localhost中运行良好。现在我正试图在web主机上托管它。我在下上传我的项目,并从文件夹复制所有文件,我也编辑

  • 问题内容: 大家好,我在laravel和ajax中使用我的评论系统时遇到问题。实际上,它仅适用于php,但我遇到了ajax问题。 这是错误消息: 状态码:500内部服务器错误。并且错误显示:1/3 SQLSTATE [23000]:违反完整性约束:1048列’post_id’不能为null。 我正在编辑模态中的注释,我可以创建一个新注释,但是问题是使用ajax编辑它。 JS代码: 这是HTML: