I am trying to connect to an SFTP server but I am receiving the following exception:
com.jcraft.jsch.JSchException: Algorithm negotiation fail
When using the following connection code:
final JSch jsch = new JSch();
jsch.addIdentity(
username,
privateKey.getBytes(),
publicKey.getBytes(),
null
);
Session jschSession = jsch.getSession("username", "server.com");
jschSession.setConfig("StrictHostKeyChecking", "no");
jschSession.connect();
Channel channel = jschSession.openChannel("sftp");
channel.connect();
return (ChannelSftp) channel;
I am getting the following error:
Connecting to server.com port 22
Connection established
Remote version string: SSH-2.0-AWS_SFTP_1.1
Local version string: SSH-2.0-JSCH-0.1.54
CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
SSH_MSG_KEXINIT sent
SSH_MSG_KEXINIT received
kex: server: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256
kex: server: rsa-sha2-512,rsa-sha2-256
kex: server: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr
kex: server: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr
kex: server: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
kex: server: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
kex: server: none,zlib@openssh.com
kex: server: none,zlib@openssh.com
kex: server:
kex: server:
kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
kex: client: none
kex: client: none
kex: client:
kex: client:
Disconnecting from server.com port 22
com.jcraft.jsch.JSchException: Algorithm negotiation fail
I believe the server is an AWS Transfer Family SFTP box using TransferSecurityPolicy-2022-03
as defined here -> https://docs.aws.amazon.com/transfer/latest/userguide/security-policies.html#cryptographic-algorithms
It appears this library is too old to connect? I am using the latest version JSch (0.1.55) and using Corretto v17 which already has Java Unlimited Strength Cryptography enabled by default.
Thoughts?