我正在尝试使用(JSCh)建立一个SFTP连接。我的软件栈是RedHatEnterpriseServer5.0、JRE6.0和JSch v0.1.44。主要的服务器软件栈(我正在试图连接到的)是Windows 2008和最新版本的GlobalScape。当我试图连接到它时,我得到了一个
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因此,从外观上看,我连接到服务器,实际上我可以发送和接收一个msg,但是当客户机试图匹配服务器msg建议和客户端msg建议时,它会抛出一个异常。
现在将它与成功连接到服务器的JSch日志与以前的GlobalScape软件和Windows 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安全性使用的是公钥/私钥和用户名/密码。
I可以使用WinSCP、Filezilla和linux命令行(从运行java应用程序的同一服务器)连接到它。
我与SFTP服务器的一位系统管理员进行了交谈,我们尝试使用用户名/密码,我得到了相同的异常和日志。
系统管理员告诉我,这两台服务器之间的区别是GlobalScape版本,现在是Microsoft2008Server。
有谁想过如何解决这个问题吗?
事先非常感谢!
发布于 2016-09-06 20:02:38
您所遇到的问题与globalscape无关,它涉及所有已启用的密码算法、SFTP服务器。每个sftp服务器都有他们一致同意的一些密码算法,所以如果您没有密码编码和密码算法,那么所有其他SFTP软件都有内置的密码算法,它们根据sftp服务器配置的最新256位密码算法进行配置,并且您都已经设置好了。
https://enterprisedt.com/products/edtftpjssl/doc/manual/html/howtousesftpchoosingalgorithms.html
公钥算法
可以为服务器身份验证的首选公钥算法设置DSA或RSA或两者。例如,如果设置了RSA,服务器将向客户端显示RSA公钥(当然,如果服务器支持RSA密钥--有些服务器不支持RSA公钥)。下面的代码说明了如何只设置RSA。它首先禁用所有键盘算法,然后启用RSA:
ftp.disableAllAlgorithms(SSHFTPAlgorithm.KEY_PAIR);ftp.setAlgorithmEnabled(SSHFTPAlgorithm.KEY_RSA,真);
默认情况是启用了DSA和RSA。
密码算法
密码算法是用来对SFTP数据和命令进行加密的对称算法。下面的代码说明了如何将三重DES设置为密码算法(禁用所有其他算法):
ftp.disableAllAlgorithms(SSHFTPAlgorithm.CIPHER);ftp.setAlgorithmEnabled(SSHFTPAlgorithm.CIPHER_3DES_CBC,真);
默认的是启用所有密码算法。
https://stackoverflow.com/questions/5564533
复制相似问题