jsch密钥交换失败,无法登陆ssh

INFO: Connecting to 192.168.170.124 port 22
INFO: Connection established
INFO: Remote version string: SSH-2.0-OpenSSH_7.2
INFO: Local version string: SSH-2.0-JSCH-0.1.53
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: diffie-hellman-group14-sha1 is not available.
INFO: ecdh-sha2-nistp256 is not available.
INFO: ecdh-sha2-nistp384 is not available.
INFO: ecdh-sha2-nistp521 is not available.
INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
INFO: ecdsa-sha2-nistp256 is not available.
INFO: ecdsa-sha2-nistp384 is not available.
INFO: ecdsa-sha2-nistp521 is not available.
INFO: SSH_MSG_KEXINIT sent
INFO: SSH_MSG_KEXINIT received
INFO: kex: server: curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
INFO: kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-ed25519
INFO: kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr
INFO: kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr
INFO: kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
INFO: kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
INFO: kex: server: none,zlib@openssh.com
INFO: kex: server: none,zlib@openssh.com
INFO: kex: server:
INFO: kex: server:
INFO: kex: client: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
INFO: kex: client: ssh-rsa,ssh-dss
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: client: none
INFO: kex: client: none
INFO: kex: client:
INFO: kex: client:
INFO: kex: server->client aes128-ctr hmac-sha1 none
INFO: kex: client->server aes128-ctr hmac-sha1 none
INFO: SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
INFO: expecting SSH_MSG_KEX_DH_GEX_GROUP
INFO: Disconnecting from 192.168.170.124 port 22
com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
有大神解决这个问题了吗

问题解决了吗?我也遇到同样的问题,升级到 ssh7 后连接不上了

我也遇到这样的问题,2017-09-12 23:53:29,510 INFO main -
com.jcraft.jsch.Session.connect(Session.java:204) => Connecting to sftp.sh.bankofbeijing.com.cn port 2022
2017-09-12 23:53:29,553 INFO main -
com.jcraft.jsch.Session.connect(Session.java:245) => Connection established
2017-09-12 23:53:29,571 INFO main -
com.jcraft.jsch.Session.connect(Session.java:301) => Remote version string: SSH-2.0-OpenSSH_7.5
2017-09-12 23:53:29,571 INFO main -
com.jcraft.jsch.Session.connect(Session.java:303) => Local version string: SSH-2.0-JSCH-0.1.54
2017-09-12 23:53:29,571 INFO main -
com.jcraft.jsch.Session.checkCiphers(Session.java:2461) => CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
2017-09-12 23:53:29,833 INFO main -
com.jcraft.jsch.Session.checkKexes(Session.java:2512) => CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
2017-09-12 23:53:29,844 INFO main -
com.jcraft.jsch.Session.checkKexes(Session.java:2530) => diffie-hellman-group14-sha1 is not available.
2017-09-12 23:53:29,844 INFO main -
com.jcraft.jsch.Session.checkKexes(Session.java:2530) => ecdh-sha2-nistp256 is not available.
2017-09-12 23:53:29,845 INFO main -
com.jcraft.jsch.Session.checkKexes(Session.java:2530) => ecdh-sha2-nistp384 is not available.
2017-09-12 23:53:29,845 INFO main -
com.jcraft.jsch.Session.checkKexes(Session.java:2530) => ecdh-sha2-nistp521 is not available.
2017-09-12 23:53:29,845 INFO main -
com.jcraft.jsch.Session.checkSignatures(Session.java:2553) => CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
2017-09-12 23:53:29,846 INFO main -
com.jcraft.jsch.Session.checkSignatures(Session.java:2575) => ecdsa-sha2-nistp256 is not available.
2017-09-12 23:53:29,846 INFO main -
com.jcraft.jsch.Session.checkSignatures(Session.java:2575) => ecdsa-sha2-nistp384 is not available.
2017-09-12 23:53:29,847 INFO main -
com.jcraft.jsch.Session.checkSignatures(Session.java:2575) => ecdsa-sha2-nistp521 is not available.
2017-09-12 23:53:29,847 INFO main -
com.jcraft.jsch.Session.send_kexinit(Session.java:694) => SSH_MSG_KEXINIT sent
2017-09-12 23:53:29,848 INFO main -
com.jcraft.jsch.Session.connect(Session.java:316) => SSH_MSG_KEXINIT received
2017-09-12 23:53:29,850 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
2017-09-12 23:53:29,850 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
2017-09-12 23:53:29,850 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
2017-09-12 23:53:29,851 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
2017-09-12 23:53:29,851 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
2017-09-12 23:53:29,851 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
2017-09-12 23:53:29,851 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: none,zlib@openssh.com
2017-09-12 23:53:29,851 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server: none,zlib@openssh.com
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server:
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:99) => kex: server:
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: ssh-rsa,ssh-dss
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
2017-09-12 23:53:29,852 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
2017-09-12 23:53:29,853 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2017-09-12 23:53:29,853 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2017-09-12 23:53:29,853 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: none
2017-09-12 23:53:29,853 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client: none
2017-09-12 23:53:29,853 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client:
2017-09-12 23:53:29,854 INFO main -
com.jcraft.jsch.KeyExchange.guess(KeyExchange.java:103) => kex: client:
2017-09-12 23:53:29,854 INFO main -

求解

JDK的加密方式有问题,导致使用diffie-hellman-group-exchange-sha256时会出现上面的问题,可以升级JDK到8,解决问题,如果没条件升级JDK,可以引入bouncycastle加密包解决问题