0

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

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • Show us [JSch log file](https://stackoverflow.com/q/47411185/850848). – Martin Prikryl Mar 16 '18 at 09:48
  • I looked at how you set up the JSch logger but It seems to me that will only return whatever message you pass. This is the stacktrace that I get from my logs. 2018-03-14 12:06:48,970 ERROR [SFTPSender] Cannot connect to sftp com.jcraft.jsch.JSchException: Algorithm negotiation fail at com.jcraft.jsch.Session.receive_kexinit(Session.java:582) ~[jsch-0.1.50.jar:?] at com.jcraft.jsch.Session.connect(Session.java:320) ~[jsch-0.1.50.jar:?] at com.jcraft.jsch.Session.connect(Session.java:183) ~[jsch-0.1.50.jar:?] – Geoffrey Griffiths Mar 16 '18 at 12:00
  • btw the jar i am using now is .54 and i am still getting the same error – Geoffrey Griffiths Mar 16 '18 at 12:01
  • The code to setup logging is in my answer to tehe question I’ve linked in my previous comment. – Martin Prikryl Mar 16 '18 at 12:12
  • Or check the second part of the answer for a standalone code to redirect specifically JSch logging to a separate log file. – Martin Prikryl Mar 16 '18 at 13:07
  • Hey Martin, i am still trying to get the logger to print to my logs in the server but for now I have managed to get some logs while debugging: aes256-ctr is not available. aes192-ctr is not available. aes256-cbc is not available. aes192-cbc is not available. aes192-cbc is not available. 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 – Geoffrey Griffiths Mar 16 '18 at 16:56
  • also this: kex: server: 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 – Geoffrey Griffiths Mar 16 '18 at 16:57
  • I will continue to get this logger set up properly – Geoffrey Griffiths Mar 16 '18 at 16:57
  • Fixed it: even though the jce_policy files where present on the environment I removed them and installed the jce_policy-8 version instead. – Geoffrey Griffiths Mar 19 '18 at 10:07
  • Good, please accept that your question is duplicate. – Martin Prikryl Mar 19 '18 at 10:17

0 Answers0