[JSch-users] diffie-hellman-group-exchange-sha1 hangs forever
Status: Alpha
Brought to you by:
ymnk
From: Tamir G. <tam...@gm...> - 2007-03-17 10:48:00
|
Hi, I was trying to use diffie-hellman-group-exchange-sha1 to connect to some servers, but every time the connection hanged forever before establishing. After doing some digging, found that the DHGEX class in the init() function is calling session.write(packet) with the command SSH_MSG_KEX_DH_GEX_REQUEST. However, in Session.write(), if in_kex it checks if the command is part of some subset of commands and otherwise sleeps and loop forever. To solve this issue I added the 4 GEX related commands to the subset of commands which are expected during key exchange, and it seem to fix the issue and connect successfully. Here is the diff of my changes, hopefully this is the correct solution for the issue: $ diff -Naur Session.java Session_new.java --- Session.java 2007-03-05 13:51:10.000000000 +0200 +++ Session_new.java 2007-03-17 12:41:18.656250000 +0200 @@ -46,6 +46,10 @@ static final int SSH_MSG_NEWKEYS= 21; static final int SSH_MSG_KEXDH_INIT= 30; static final int SSH_MSG_KEXDH_REPLY= 31; + static final int SSH_MSG_KEX_DH_GEX_GROUP= 31; + static final int SSH_MSG_KEX_DH_GEX_INIT= 32; + static final int SSH_MSG_KEX_DH_GEX_REPLY= 33; + static final int SSH_MSG_KEX_DH_GEX_REQUEST= 34; static final int SSH_MSG_GLOBAL_REQUEST= 80; static final int SSH_MSG_REQUEST_SUCCESS= 81; static final int SSH_MSG_REQUEST_FAILURE= 82; @@ -1132,7 +1136,11 @@ command==SSH_MSG_NEWKEYS || command==SSH_MSG_KEXDH_INIT || command==SSH_MSG_KEXDH_REPLY || - command==SSH_MSG_DISCONNECT){ + command==SSH_MSG_DISCONNECT || + command==SSH_MSG_KEX_DH_GEX_GROUP || + command==SSH_MSG_KEX_DH_GEX_INIT || + command==SSH_MSG_KEX_DH_GEX_REPLY || + command==SSH_MSG_KEX_DH_GEX_REQUEST){ break; } try{Thread.sleep(10);} Thanks, Tamir http://www.tamirgal.com/home/dev.aspx |