Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java org.apache.commons.vfs2.FileSystemException:无法连接到SFTP服务器_Java_Ssh_Openssl_Sftp_Jsch - Fatal编程技术网

Java org.apache.commons.vfs2.FileSystemException:无法连接到SFTP服务器

Java org.apache.commons.vfs2.FileSystemException:无法连接到SFTP服务器,java,ssh,openssl,sftp,jsch,Java,Ssh,Openssl,Sftp,Jsch,我正在尝试使用vfs2连接器连接到SFTP主机,该连接器内部使用jsch。 但是,当我尝试连接时,会出现以下异常: 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

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

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
12:50:31.747信息o.a.c.v.p.sftp.SFTPClient工厂-连接到端口
12:50:32.074信息o.a.c.v.p.sftp.SFTPClient工厂-已建立连接
12:50:32.376信息o.a.c.v.p.sftp.SFTPClient工厂-远程版本字符串:SSH-2.0-OpenSSH_7.4
12:50:32.376信息o.a.c.v.p.sftp.SFTPClient工厂-本地版本字符串:SSH-2.0-JSCH-0.1.54
12:50:32.376信息o.a.c.v.p.sftp.SFTPClient工厂-校验密码:aes256 ctr、aes192 ctr、aes128 ctr、aes256 cbc、aes192 cbc、aes128 cbc、3des ctr、ARCFORE、ARCFOR128、ARCFOR256
12:50:33.489信息o.a.c.v.p.sftp.SftpClientFactory-检查表:diffie-hellman-group14-sha1、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2-nistp521
12:50:34.192信息o.a.c.v.p.sftp.SFTPClient工厂-检查签名:ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-SSH_MSG_KEXINIT已发送
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-SSH_MSG_KEXINIT收到
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:ssh rsa、rsa-sha2-512、rsa-sha2-256、ssh-ed25519
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:chacha20-poly1305@openssh.com,aes128中心,aes192中心,aes256中心,aes128-gcm@openssh.com,aes256-gcm@openssh.com、aes128 cbc、aes192 cbc、aes256 cbc、河豚cbc、cast128 cbc、3des cbc
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:chacha20-poly1305@openssh.com,aes128中心,aes192中心,aes256中心,aes128-gcm@openssh.com,aes256-gcm@openssh.com、aes128 cbc、aes192 cbc、aes256 cbc、河豚cbc、cast128 cbc、3des cbc
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
12:50:34.203信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:无,zlib@openssh.com
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:无,zlib@openssh.com
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:服务器:
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户: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信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户端:ssh rsa、ssh dss、ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:aes128 ctr、aes128 cbc、3des ctr、3des cbc、河豚cbc、aes192 ctr、aes192 cbc、aes256 ctr、aes256 cbc
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:aes128 ctr、aes128 cbc、3des ctr、3des cbc、河豚cbc、aes192 ctr、aes192 cbc、aes256 ctr、aes256 cbc
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:hmac-md5、hmac-sha1、hmac-sha2-256、hmac-sha1-96、hmac-md5-96
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:hmac-md5、hmac-sha1、hmac-sha2-256、hmac-sha1-96、hmac-md5-96
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:无
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:无
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:
12:50:34.204信息o.a.c.v.p.sftp.SFTPClient工厂-kex:客户:
12:50:34.205信息o.a.c.v.p.sftp.SFTPClient工厂-从端口断开连接
12:50:34.243错误c.s.saw.export.SFTPUploader-IO SFTP错误:
org.apache.commons.vfs2.FileSystemException:无法连接到位于“SFTP://@:/”的SFTP服务器。
位于org.apache.commons.vfs2.provider.sftp.SftpFileProvider.createSession(SftpFileProvider.java:72)
位于org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:93)
位于org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:93)
位于org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:72)
位于org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:56)
位于org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:717)
位于org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:654)
位于com.synchronoss.saw.export.SFTPUploader.uploadFile(SFTPUploader.java:99)
位于com.synchronoss.saw.export.SFTPUploader.main(SFTPUploader.java:134)
原因:org.apache.commons.vfs2.FileSystemException:无法连接到位于“”的SFTP服务器。
位于org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:163)
位于org.apache.commons.vfs2.provider.sftp.SftpFileProvider.createSession(SftpFileProvider.java:65)
... 省略了8个公共框架
原因:com.jcraft.jsch.JSchException:算法协商失败
在com.jcraft.jsch.Session.receive_kexinit上(Session.java:590)
位于com.jcraft.jsch.Session.connect(Session.java:320)
位于com.jcraft.jsch.Session.connect(Session.java:183)
位于org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:161)
... 省略9个公共框架
我参考了一些博客和stackoverflow链接,并尝试了多种方法。我仍然没有得到任何成功的结果。此外,尝试了vfs2和jsch的多个版本,但都没有成功

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

config.put("hmac-sha2-256-etm@openssh.com", "com.jcraft.jsch.jce.HMACSHA256");