2011-04-06 70 views
1

我试图建立一个使用Java安全通道(JSCh)的SFTP连接。 我的软件堆栈是红帽企业服务器5.0,JRE 6.0和JSch v0.1.44。 主要服务器软件堆栈(我试图连接的)是Windows Server 2008和最新版本的GlobalScape。 当试图连接到它,我得到一个使用JSch和GlobalScape的SFTP

com.jcraft.jsch.JSchException: Algorithm negotiation fail 
    at com.jcraft.jsch.Session.receive_kexinit(Session.java:529) 
    at com.jcraft.jsch.Session.connect(Session.java:291) 

启用JSch记录我得到这个相同的连接如下:

0000001d SystemErr  R INFO: Connecting to xxx.xxx.xxx.157 port 22 
0000001d SystemErr  R INFO: Connection established 
0000001d SystemErr  R INFO: Remote version string: SSH-2.0-1.36_sshlib GlobalSCAPE 
0000001d SystemErr  R INFO: Local version string: SSH-2.0-JSCH-0.1.44 
0000001d SystemErr  R INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256- cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 
0000001d SystemErr  R INFO: aes256-ctr is not available. 
0000001d SystemErr  R INFO: aes192-ctr is not available. 
0000001d SystemErr  R INFO: aes256-cbc is not available. 
0000001d SystemErr  R INFO: aes192-cbc is not available. 
0000001d SystemErr  R INFO: arcfour256 is not available. 
0000001d SystemErr  R INFO: SSH_MSG_KEXINIT sent 
0000001d SystemErr  R INFO: SSH_MSG_KEXINIT received 
0000001d SystemErr  R INFO: Disconnecting from xxx.xxx.xxx.157 port 22 
从我连接到服务器的它看起来

所以和我实际上可以发送和接收消息,但是当客户端尝试匹配服务器消息提议和客户端消息提议时,它会引发异常。

现在有了成功连接到服务器与以前GlobalScape软件的JSch日志比较它的Windows Server 2003:

0000001e SystemErr  R INFO: Connecting to xxx.xxx.xxx.156 port 22 
0000001e SystemErr  R INFO: Connection established 
0000001e SystemErr  R INFO: Remote version string: SSH-2.0-1.36 sshlib: GlobalScape 
0000001e SystemErr  R INFO: Local version string: SSH-2.0-JSCH-0.1.44 
0000001e SystemErr  R INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 
0000001e SystemErr  R INFO: aes256-ctr is not available. 
0000001e SystemErr  R INFO: aes192-ctr is not available. 
0000001e SystemErr  R INFO: aes256-cbc is not available. 
0000001e SystemErr  R INFO: aes192-cbc is not available. 
0000001e SystemErr  R INFO: arcfour256 is not available. 
0000001e SystemErr  R INFO: SSH_MSG_KEXINIT sent 
0000001e SystemErr  R INFO: SSH_MSG_KEXINIT received 
0000001e SystemErr  R INFO: kex: server->client aes128-cbc hmac-md5 none 
0000001e SystemErr  R INFO: kex: client->server aes128-cbc hmac-md5 none 
0000001e SystemErr  R INFO: SSH_MSG_KEXDH_INIT sent 
0000001e SystemErr  R INFO: expecting SSH_MSG_KEXDH_REPLY 
0000001e SystemErr  R INFO: ssh_dss_verify: signature true 
0000001e SystemErr  R WARN: Permanently added 'xxx.xxx.xxx.156' (DSA) to the list of known hosts. 
0000001e SystemErr  R INFO: SSH_MSG_NEWKEYS sent 
0000001e SystemErr  R INFO: SSH_MSG_NEWKEYS received 
0000001e SystemErr  R INFO: SSH_MSG_SERVICE_REQUEST sent 
0000001e SystemErr  R INFO: SSH_MSG_SERVICE_ACCEPT received 
0000001e SystemErr  R INFO: Authentications that can continue: publickey,keyboard-inteactive,password 
0000001e SystemErr  R INFO: Next authentication method: publickey 
0000001e SystemErr  R INFO: Authentications that can continue: password 
0000001e SystemErr  R INFO: Next authentication method: password 
0000001e SystemErr  R INFO: Authentication succeeded (password). 

所以再次它能够连接并能够交换SSH_MSG_KEXINIT,但在这里客户端和服务器提议匹配且不会引发异常

sftp安全性使用公钥/私钥和用户名/密码。

我可以使用WinSCP,Filezilla和linux命令行(从运行java应用程序的相同服务器)连接到它。

我与SFTP服务器的一位系统管理员交谈过,我们尝试使用用户名/密码,并得到相同的异常和日志。

系统管理员告诉我,两台服务器之间的区别是GlobalScape版本,现在是Microsoft 2008 Server。

因此,任何人都有如何解决这个问题的想法?

非常感谢提前!

+0

我看到它的正确设置的主要区别是您的GlobalScape版本吗?看看配置,最新版本是否允许带hmac-md5的aes128-cbc? – 2011-04-06 12:23:02

+0

如果你可以在调试器中运行你的程序,你可以尝试在'Session.send_keyinit()'的中间放一个断点来查看'ciphersc2s'和'cipherss2c'的值。或者在那里放一个'.log(...)'。 – 2011-04-06 12:33:06

+0

是的,迄今在JSch日志上的主要区别是GlobalScape版本。我已经与该服务器的系统管理员交谈过,他正在检查它。感谢这篇文章。 – 2011-04-06 13:53:41

回答

0

您遇到的问题与globalscape无关,它关于所有启用的密码算法SFTP服务器都是无关的。 每个sftp服务器都有一些他们同意的密码算法,所以如果你没有这些密码编码和算法,它不会工作 密码算法 所有其他SFTP软件都有内置的密码算法,它们根据sftp服务器配置chnage使用最新的256位加密算法,你都设置

https://enterprisedt.com/products/edtftpjssl/doc/manual/html/howtousesftpchoosingalgorithms.html

公共密钥算法

无论DSA或RSA或两者可为服务器身份验证的首选公钥算法进行设置。例如,如果设置了RSA,则服务器将向客户端呈现RSA公钥(如果服务器支持RSA密钥 - 当然有些服务器不支持)。下面的代码说明了如何仅设置RSA。它首先禁用所有密钥对算法,然后启用RSA:

ftp.disableAllAlgorithms(SSHFTPAlgorithm.KEY_PAIR); ftp.setAlgorithmEnabled(SSHFTPAlgorithm。KEY_RSA,true);

默认值是启用DSA和RSA。

密码算法

的密码算法是用于执行SFTP数据和命令的加密的对称算法。以下代码说明如何将三重DES设置为密码算法(禁用所有其他密码算法):

ftp.disableAllAlgorithms(SSHFTPAlgorithm.CIPHER); ftp.setAlgorithmEnabled(SSHFTPAlgorithm.CIPHER_3DES_CBC,true);

默认值是所有启用的密码算法。