I know this question has been asked several times before and I have tried all of the solutions offered including:
1) adding these to the sshd_config file curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1, diffie-hellman-group1-sha1
2) updating the jsch-0.1.50.jar to jsch-0.1.54.jar
3) restarting the ssh server
I am running java 8 and using a Jetty server. If anyone has something else I can try to resolve this, I would be very appreciative.
my java code:
public void connect() {
try {
JSch jsch = new JSch();
if(!"${company.sftp.password}".equals(password)){
session = jsch.getSession(username, host);
session.setPassword(password);
}
else {
jsch.addIdentity(keyPath);
session = jsch.getSession(username,host);
}
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
logger.info("Connection to {}", host);
sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect();
logger.info("Connected to sftp");
sftpChannel.cd(path);
logger.info("Using directory {}", path);
} catch (JSchException e) {
logger.error("Cannot connect to sftp", e);
} catch (SftpException e) {
logger.error("Problem with sftp connection", e);
}
}
I am not using a password and so the keypath points to /home/companyname/.ssh/id_rsa