思科交换机上的libssh导致ssh_connect()超时

时间:2019-05-20 12:46:06

标签: c++ cisco libssh

我正在尝试编写一个小程序来自动配置Cisco SG350交换机。我已经为其他网络交换机完成了此操作,但是我对SG350感到困惑。在ssh_connect(my_ssh_session)期间,程序挂起并超时。

我正在Windows 10和libssh 0.7.6-1(通过vcpkg安装)上使用Visual Studio 2017。 Cisco SG350具有固件(FW)版本2.4.5.71,我可以使用腻子通过ssh连接登录。

我只使用了提到的libssh版本,因为那是vcpkg的最新版本,到目前为止,我一直没有自己编译它。

我尝试对Cisco交换机使用不同的FW版本,以查看是否有任何改变。固件2.5.0.78版显示了相同的问题。

有人对此有经验或有类似问题吗?下面是一个不进行身份验证的最小工作示例,因为超时发生较早。

#include <libssh/libssh.h> // C lib


int main() {
    ssh_session my_ssh_session;
    int rc;
    int verbosity = SSH_LOG_FUNCTIONS;

    // Open Session and set Options
    my_ssh_session = ssh_new();
    if (my_ssh_session == NULL) return 1;

    ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "10.0.0.1");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "user");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);

    // Connect to server
    rc = ssh_connect(my_ssh_session);
    if (rc != SSH_OK) {
        std::cerr << "ERROR connecting to host: ";
        std::cerr << ssh_get_error(my_ssh_session);
        ssh_free(my_ssh_session);
        return 1;
    }

    // Verify server's identity
    /* tbd */

    // Authenticate ourselves
    /* tbd */

    ssh_disconnect(my_ssh_session);
    ssh_free(my_ssh_session);

    return 0;
}

sshlib日志显示以下内容:

[2019/05/20 13:35:56.636856, 2] ssh_connect:  libssh 0.7.6 (c) 2003-2014 Aris Adamantiadis, Andreas Schneider, and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_noop
[2019/05/20 13:35:56.646800, 3] getai:  host 10.0.0.1 matches an IP address
[2019/05/20 13:35:56.649788, 2] ssh_socket_connect:  Nonblocking connection socket: 588
[2019/05/20 13:35:56.651805, 2] ssh_connect:  Socket connecting, now waiting for the callbacks to work
[2019/05/20 13:35:56.665747, 3] ssh_connect:  Actual timeout : 10000
[2019/05/20 13:35:56.669748, 3] ssh_socket_pollcallback:  Received POLLOUT in connecting state
[2019/05/20 13:35:56.682721, 1] socket_callback_connected:  Socket connection callback: 1 (0)
[2019/05/20 13:35:56.684696, 3] ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
[2019/05/20 13:35:56.698660, 3] callback_receive_banner:  Received banner: SSH-2.0-OpenSSH_7.3p1.RL
[2019/05/20 13:35:56.701651, 1] ssh_client_connection_callback:  SSH server banner: SSH-2.0-OpenSSH_7.3p1.RL
[2019/05/20 13:35:56.723595, 1] ssh_analyze_banner:  Analyzing banner: SSH-2.0-OpenSSH_7.3p1.RL
[2019/05/20 13:35:56.739578, 1] ssh_analyze_banner:  We are talking to an OpenSSH client version: 7.3 (70300)
[2019/05/20 13:36:06.669411, 1] ssh_connect:  Timeout connecting to 10.0.0.1
[2019/05/20 13:36:06.671405, 3] ssh_connect:  current state : 9

作为旁注: 我还尝试了FW 2.3.5.63版本,该版本最初是从那里开始的。在那里可以建立连接并可以打开通道,但是当再次关闭ssh通道时,我有一个奇怪的行为,这导致出现“客户端已连接”错误消息,并且ssh连接将断开。 因此,我想看看更新的固件是否更流畅。

0 个答案:

没有答案