【问题标题】:libssh crypt_set_algorithms2 errorlibssh crypt_set_algorithms2 错误
【发布时间】:2015-11-22 22:41:37
【问题描述】:

大家好,我正在尝试在 Windows 应用程序(我编写的程序)和 ssh 服务器之间建立简单的 ssh 连接。在我的代码中,我使用 libssh,但出现这样的错误: crypt_set_algorithms2: 没有找到 3des-cbc 的加密算法函数

我使用的代码是:

#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h> 
int main()
{
    ssh_session my_ssh_session;
    int rc;
    int port = 22;
    int verbosity = SSH_LOG_PROTOCOL;
    char *password;
    // Open session and set options
    my_ssh_session = ssh_new();
    if (my_ssh_session == NULL)
        exit(-1);
    ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "192.168.1.6");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "john");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
    ssh_options_set(my_ssh_session, SSH_OPTIONS_CIPHERS_C_S,"aes128-ctr");

    //ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
    // Connect to server
    rc = ssh_connect(my_ssh_session);
    if (rc != SSH_OK)  
    {
        fprintf(stderr, "Error: %s\n", ssh_get_error(my_ssh_session)); //HERE IS WHERE I GET THE ERROR 
        ssh_free(my_ssh_session);
        exit(-1);
    }
    // Verify the server's identity
    // For the source code of verify_knowhost(), check previous example
/*  if (verify_knownhost(my_ssh_session) < 0)
    {
        ssh_disconnect(my_ssh_session);
        ssh_free(my_ssh_session);
        exit(-1);
    }
*/  
    // Authenticate ourselves
    password = "pass";
    rc = ssh_userauth_password(my_ssh_session, NULL, password);
    if (rc != SSH_AUTH_SUCCESS)
    {
        fprintf(stderr, "Error authenticating with password: %s\n",
            ssh_get_error(my_ssh_session));
        ssh_disconnect(my_ssh_session);
        ssh_free(my_ssh_session);
        exit(-1);
    }


        ssh_disconnect(my_ssh_session);
    ssh_free(my_ssh_session);
}

【问题讨论】:

    标签: c++ ssh visual-studio-2015 libssh


    【解决方案1】:

    您的程序指定连接必须使用aes128-ctr 密码,并且没有列出任何替代方案。您收到的错误消息表明服务器不支持此密码。尝试注释掉 SSH_OPTIONS_CIPHERS_C_S 行,或将参数更改为包含服务器支持的密码的列表(根据您所说的,3des-cbc 可能有效)。要指定密码列表,请使用带有逗号分隔密码名称的字符串,例如"aes128-ctr,aes256-ctr,3des-cbc"

    但除非您知道自己在做什么,否则请坚持使用默认设置,不要指定任何显式密码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-01
      • 2020-12-19
      • 1970-01-01
      • 2022-11-01
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多