2011-04-06 68 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);

默認值是所有啓用的密碼算法。