如何在使用Apache VFS时在JSch Session上设置KEX [英] How to set KEX on JSch Session when using Apache VFS

查看:188
本文介绍了如何在使用Apache VFS时在JSch Session上设置KEX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Apache VFS 2.1 JSch 0.1.54 (今日最新版本)使用SFTP上传文件。

I am using Apache VFS 2.1 with JSch 0.1.54 (latest versions today) to upload files using SFTP.

系统在连接时抛出IO流读取结束,完整的堆栈是:

The system throws "End of IO Stream Read" when connecting, the complete stack is:

Caused by: com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
    at com.jcraft.jsch.Session.connect(Session.java:565)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:166)

我发现了在此主题中解决我的问题的可能方案,但它直接与JSch一起运行。由于我使用的是Apache VFS,我无法直接访问 Session (至少我认为我不能)。

I've found a possible solution to my problem in this thread but it operates directly with the JSch. Since I am using Apache VFS I can't access the Session directly (at least I think I can't).

但如果可以的话,它会是这样的:

But if I could, it would look like this:

session.setConfig("kex", "diffie-hellman-group1-sha1");

查看Apache VFS实现 org.apache.commons.vfs2.provider .sftp.SftpClientFactory 它没有找到设置此属性的方法。

Looking into the Apache VFS implementation org.apache.commons.vfs2.provider.sftp.SftpClientFactory it didn't find a way to set this property.

如何使用Apache VFS API设置此配置?

How can I set this configuration using Apache VFS API?

日志数据:

22/05/2017 09:27:20 org.apache.commons.vfs2.impl.StandardFileSystemManager info
INFO: Using "D:\Users\TECBMEPI\AppData\Local\Temp\vfs_cache" as temporary files store.
22/05/2017 09:27:20 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: Connecting to z1t1brmxpta022 port 22
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: Connection established
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: Remote version string: SSH-2.0-OpenSSH_6.6.1
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: Local version string: SSH-2.0-JSCH-0.1.54
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: aes256-ctr is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: aes192-ctr is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: aes256-cbc is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: aes192-cbc is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: diffie-hellman-group14-sha1 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdh-sha2-nistp256 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdh-sha2-nistp384 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdh-sha2-nistp521 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdsa-sha2-nistp256 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdsa-sha2-nistp384 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: ecdsa-sha2-nistp521 is not available.
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: SSH_MSG_KEXINIT sent
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: SSH_MSG_KEXINIT received
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: none,zlib@openssh.com
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: none,zlib@openssh.com
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: 
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server: 
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: ssh-rsa,ssh-dss
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: none
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: none
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: 
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client: 
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: server->client aes128-ctr hmac-md5 none
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: kex: client->server aes128-ctr hmac-md5 none
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: expecting SSH_MSG_KEX_DH_GEX_GROUP
22/05/2017 09:27:21 org.apache.commons.vfs2.provider.sftp.SftpClientFactory log
INFO: Disconnecting from z1t1brmxpta022 port 22


推荐答案

JSch 会话从其 JSch 实例继承设置。并且所有 JSch 实例实际上与设置共享相同的全局/静态哈希表。

The JSch Session inherits settings from its JSch instance. And all JSch instances actually share the same global/static hashtable with settings.

所以只需调用static SftpClientFactory.createConnection 之前 JSch.setConfig

So just call static JSch.setConfig before SftpClientFactory.createConnection:

JSch.setConfig("kex", "diffie-hellman-group1-sha1");

这篇关于如何在使用Apache VFS时在JSch Session上设置KEX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆