我使用单个线程应用程序连接我的客户端服务器体系结构。基本上,这个应用程序将创建许多连接&在作业完成后自动关闭它。我们得到了一个例外
'com.sshtools.j2ssh.transport.TransportProtocolException:连接没有完成‘’
我们已经启用了j2ssh日志来找出问题的根源。下面是有关这个问题的全部细节。
Java版本: jdk1.6.0_11
使用的API : J2SSH Core 0.2.9 (j2ssh-core-0.2.9.jar)
com.sshtools.j2ssh.transport.TransportProtocolException: The connection did not complete
at com.sshtools.j2ssh.transport.TransportProtocolClient.onStartTransportProtocol(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.startTransportProtocol(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at info.itserv.globalinterface.gui.SFTP.openSSH(SFTP.java:95)
at info.itserv.globalinterface.gui.SFTP.connectionSFTP(SFTP.java:228).和下面的代码
public void openSSH(String hostname, int authCode) {
try {
sshClient.connect(hostname,
new IgnoreHostKeyVerification());
sshClient.getConnectionProperties().setPort(this.port);
//Authenticate
GENERAL.println("Processing logging...");
switch (authCode) {
case 0:
this.login(this.username, this.password);
System.out.println("Password authentication");
break;
case 1:
//String keyFilename = "D:\\Cygwin\\home\\gtantot\\id_dsa";
this.loginCertificat(this.username, this.keyFilename,
this.passphrase);
System.out.println("Password authentication");
break;
default:
System.out.println("ECHEC SSH connection");
break;
}
this.sftp = sshClient.openSftpClient();
} catch (TransportProtocolException e) {
System.out.println("Transport: "+e.getMessage().toString() );
e.printStackTrace();
}
catch (IOException e1) {
System.out.println("Error openSSH: "+e1.getMessage());
e1.printStackTrace();
} }
public void closeSSH() {
if (sshClient != null) {
sshClient.disconnect();
}
}有什么办法克服这个错误吗?由于这种错误会导致应用程序的一个sftp会话失败,那么解决方案是什么?
发布于 2015-03-25 09:08:58
如果您已经发布了完整的日志,应该有更多的输出,您是否将日志打开到调试级别?
查看代码--此异常发生在密钥交换期间发生故障时,您连接到的服务器可能不支持旧的J2SSH API支持的任何密钥交换算法。
您正在使用的J2SSH版本可能已经在2009年发布,但是自从2007年最初的作者停止了贡献以来,几乎没有什么工作被投入到API中。许多服务器现在禁用旧的、不太安全的密钥交换,这可能是造成问题的原因之一。
如果您想继续使用类似于J2SSH的API而不是JSch,您可以使用J2SSH Maverick的开源版本,它来自与J2SSH相同的作者(这是me顺便说一句)。
https://stackoverflow.com/questions/29248448
复制相似问题