1

I can't connect to my server via Jsch. I'm getting

com.jcraft.jsch.JSchException: Algorithm negotiation fail

pom looks like that

    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.53</version>
    </dependency>

my Code looks like that

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class UserAuthPubKey {
    public static void main(String[] arg) {
        try {
            JSch jsch = new JSch();

            String user = "....";
            String host = "....";
            String privateKey = "C:\\Users\\user\\.ssh\\id_rs_user";

            jsch.addIdentity(privateKey);

            Session session = jsch.getSession(user, host, 22);

            session.connect();
            System.out.println("session connected.....");

        } catch (Exception e) {
            System.err.println(e);
        }
    }
}

I had to replace the JRE - java unlimited strength policy. That solved my problem

Robert Rieser
  • 63
  • 1
  • 7

0 Answers0