Jcraft с CopSSH выдает ошибку сбоя согласования алгоритма в среде Windows

Я разрабатываю Java-программу для связи с Windows Server через SSH. Для этого я использовал jcraft на Java. И сервер SSH является CopSSH. Реализация бросков

Ошибка: com.jcraft.jsch.JSchException: сбой согласования алгоритма

ошибка на Java. В то же время это показывает

Неустранимый: Невозможно договориться с 192.168.28.111: не найден соответствующий шифр. Их предложение: aes128-cbc,3des-cbc,blowfish-cbc [preauth]

на CopSSH.

Блок кода Java

public void sshExecPassword(String host, String USERNAME, String PASSWORD, String command) {
    App objApp = new App();
    int port = 22;
    try {
        /**
         * Create a new Jsch object This object will execute shell commands
         * or scripts on server
         */
        JSch jsch = new JSch();

        /*
         * Open a new session, with your username, host and port Set the
         * password and call connect. session.connect() opens a new
         * connection to remote SSH server. Once the connection is
         * established, you can initiate a new channel. this channel is
         * needed to connect to remotely execution program
         */
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");

        Session session = jsch.getSession(USERNAME, host, port);
        session.setConfig(config);
        session.setPassword(PASSWORD);
        session.connect();

        // create the excution channel over the session
        ChannelExec channelExec = (ChannelExec) session.openChannel("exec");

        // Gets an InputStream for this channel. All data arriving in as
        // messages from the remote side can be read from this stream.
        InputStream in = channelExec.getInputStream();

        // Set the command that you want to execute
        // In our case its the remote shell script
        String str = command;
        channelExec.setCommand(str);
        channelExec.connect();

        // Read the output from the input stream we set above
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line;
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }

        // retrieve the exit status of the remote command corresponding to
        // this channel
        int exitStatus = channelExec.getExitStatus();

        // Safely disconnect channel and disconnect session. If not done
        // then it may cause resource leak
        channelExec.disconnect();
        session.disconnect();

        if (exitStatus < 0) {
            System.out.println("Done, but exit status not set! " + exitStatus);
            objApp.writeLogs("120","Done, but exit status not set! ");
        } else if (exitStatus > 0) {
            System.out.println("Done, but with error!");
            objApp.writeLogs("120","Done, but with error!");
        } else {
            System.out.println("Done!");
            objApp.writeLogs("121","SSH connection successful");
        }

    } catch (Exception e) {
        System.err.println("Error: " + e);
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        e.printStackTrace(pw);
        objApp.writeLogs("120", sw.getBuffer().toString());
    }
}

И хост CopSSH следующих версий

OpenSSH_7.1p2, OpenSSL 1.0.2e 3 декабря 2015 г.

Кто-нибудь может предложить исправить это?

2 ответа

Это происходит из-за отсутствия поддержки устаревших шифров в более поздних выпусках OpenSSH. Проверьте этот Copssh FAQ для решения. Справочную информацию также можно найти здесь.

Последний jcraft jar исправить проблему

Другие вопросы по тегам