尝试建立连接时,JSch会话挂起

时间:2019-08-19 15:19:31

标签: jsch

我正在使用com.jcraft.jsch版本0.1.55并连接到多个Linux服务器,一次连接一个。一些服务器连接成功,而另一些则不成功。

表面上,服务器中的代码是相同的。我需要找出为什么会有不同的行为。

客户代码。设置

JSch jsch = new JSch();
Session session = jsch.getSession("username", ip_address, 22);
session.setPassword("password");
session.setConfig("StrictHostKeyChecking","no");
session.connect()

等待调用UserAuthGSSAPIWithMIC.start()

工作流程:

Session.start()
line 22 super.start(session) sets buf[5] = 51
line 25 this.buf.putByte((byte)50) sets buf[5] = 50
flow continues to line 39 this.buf = session.read(this.buf) which returns
and has set buf[5] to 51 forcing the auth to move on the next auth method.
Eventually succeeds using the password method

断流:

Session.start()
super.start() sets buf[5] = 51
this.buf.putByte((byte)50) sets buf[5] = 50
flow continues to line 39 this.buf = session.read(this.buf) which returns 
and has set buf[5] to 60 which sends the code to create a new context, 
part of which calls oid.equals() which hangs on line 160 -
return this.oid.equals.((Object) ((Oid) other).oid);

此部分代码中没有日志消息,因此没有有关代码正在执行的信息。

我可以通过设置session.setConfig(“ PreferredAuthentications”,“ password”);来解决问题

我想知道为什么代码在某些服务器而不是其他服务器上挂在UserAuthGSSAPIWithMIC上。还有如何获取一些有用的日志记录信息。

0 个答案:

没有答案
相关问题