Java: InvalidAlgorithmParameterException Prime size must be multiple of 64

前端 未结 9 1962
北海茫月
北海茫月 2020-12-10 16:01

I implemented a Java program that will connect and execute a command in a remote server using JSCH. The problem is that whenever I tried to connect to the server, I got the

9条回答
  •  自闭症患者
    2020-12-10 16:37

    Add this line of code after you have the Session instance:

    public static Session createSession(Server srv){
       JSch js = new JSch();
       try {
          Session s = js.getSession(srv.getUser().getUsername(), srv.getAddress(), 22);
          s.setPassword(srv.getUser().getPassword());
          Properties config = new Properties();
          config.put("StrictHostKeyChecking", "no");
          config.put("PreferredAuthentications", "password");
          config.put("kex", "diffie-hellman-group1-sha1");
          s.setConfig(config);
          ...
    

    The line to be added is: config.put("kex", "diffie-hellman-group1-sha1");

提交回复
热议问题