我正在使用Spring集成(版本:6.1.2)连接到SFTP服务器.在创建SFTP会话时,我遇到此异常-
java.lang.IllegalStateException: failed to create SFTP Session
....
Caused by: org.apache.sshd.common.SshException: Unable to negotiate key exchange for kex algorithms (
client:
curve25519-sha256,
curve25519-sha256@libssh.org,
curve448-sha512,
ecdh-sha2-nistp521,
ecdh-sha2-nistp384,
ecdh-sha2-nistp256,
diffie-hellman-group-exchange-sha256,
diffie-hellman-group18-sha512,
diffie-hellman-group17-sha512,
diffie-hellman-group16-sha512,
diffie-hellman-group15-sha512,
diffie-hellman-group14-sha256,
ext-info-c
server:
diffie-hellman-group1-sha1,
diffie-hellman-group14-sha1)
显然,服务器只支持旧的算法.如何在我的SFTP会话中添加对这些算法的支持?
我的密码是这样的-
DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory();
factory.setHost("ftp.sssss.com");
factory.setPort(Integer.valueOf(22));
factory.setAllowUnknownKeys(true);
factory.setUser("user");
factory.setPassword("password");
SftpSession sftpSession = factory.getSession();