gpt4 book ai didi

java - org.apache.commons.vfs2.FileSystemException : Could not connect to SFTP server

转载 作者:行者123 更新时间:2023-12-02 14:27:09 28 4
gpt4 key购买 nike

我正在尝试使用内部使用 jsch 的 vfs2 连接器连接到 SFTP 主机。
但是,当我尝试连接时,出现以下异常:

12:50:31.747  INFO  o.a.c.v.p.sftp.SftpClientFactory - Connecting to <host> port <port>
12:50:32.074 INFO o.a.c.v.p.sftp.SftpClientFactory - Connection established
12:50:32.376 INFO o.a.c.v.p.sftp.SftpClientFactory - Remote version string: SSH-2.0-OpenSSH_7.4
12:50:32.376 INFO o.a.c.v.p.sftp.SftpClientFactory - Local version string: SSH-2.0-JSCH-0.1.54
12:50:32.376 INFO o.a.c.v.p.sftp.SftpClientFactory - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
12:50:33.489 INFO o.a.c.v.p.sftp.SftpClientFactory - CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
12:50:34.192 INFO o.a.c.v.p.sftp.SftpClientFactory - CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - SSH_MSG_KEXINIT sent
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - SSH_MSG_KEXINIT received
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-ed25519
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
12:50:34.203 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: none,zlib@openssh.com
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server: none,zlib@openssh.com
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server:
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: server:
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - 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
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: none
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client: none
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client:
12:50:34.204 INFO o.a.c.v.p.sftp.SftpClientFactory - kex: client:
12:50:34.205 INFO o.a.c.v.p.sftp.SftpClientFactory - Disconnecting from <host> port <port>
12:50:34.243 ERROR c.s.saw.export.SFTPUploader - IO SFTP Error:
org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "sftp://<user>@<host>:<port>/".
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.createSession(SftpFileProvider.java:72)
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:93)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:93)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:72)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:56)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:717)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:654)
at com.synchronoss.saw.export.SFTPUploader.uploadFile(SFTPUploader.java:99)
at com.synchronoss.saw.export.SFTPUploader.main(SFTPUploader.java:134)
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "<host>".
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:163)
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.createSession(SftpFileProvider.java:65)
... 8 common frames omitted
Caused by: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:590)
at com.jcraft.jsch.Session.connect(Session.java:320)
at com.jcraft.jsch.Session.connect(Session.java:183)
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:161)
... 9 common frames omitted

我引用了一些博客和 stackoverflow 链接并尝试了多种方法。我仍然没有得到任何成功的结果。此外,尝试了多个版本的 vfs2 和 jsch 均无济于事。

以下是我提到的一些链接:

JSchException: Algorithm negotiation fail

JSch Algorithm negotiation fail

https://dzone.com/articles/install-java-cryptography-extension-jce-unlimited

The cipher 'aes256-cbc' is required, but it is not available

有人可以帮我吗?

最佳答案

您的服务器仅支持以下 MAC:

hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com

JSch 不支持这些。

如果您需要与 JSch 连接,则必须配置您的服务器以允许 JSch 支持的一些 MAC:

hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96

使用 MACs directive in sshd_config .

虽然 hmac-sha2-*-etm@openssh.comhmac-sha2-*可能只是别名。所以适本地配置 JSch 也可能有帮助:
config.put("hmac-sha2-256-etm@openssh.com", "com.jcraft.jsch.jce.HMACSHA256");

但我不确定 vfs2 接口(interface)是否允许这样的配置。

关于java - org.apache.commons.vfs2.FileSystemException : Could not connect to SFTP server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62081282/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com