1

I use libssh to connect to a server using the following code:

sshSession { ssh_new() }

ssh_options_set(sshSession, SSH_OPTIONS_HOST, "192.168.1.190");
ssh_options_set(sshSession, SSH_OPTIONS_PORT_STR, "22");
        
ssh_set_log_level(SSH_LOG_PACKET);
ssh_set_log_callback(+[](int priority, const char* function, const char* message, void*)
{
    // Log error as "(<priority>) in <function> : <message>"
});

auto res { ssh_connect(sshSession) };

if (res != SSH_OK)
{
    // Log error
}

and it works fine on some machines, but not on others.


The log on the machine where it does not work is this:

(2) in ssh_connect : ssh_connect: libssh 0.9.6 (c) 2003-2021 Aris Adamantiadis, Andreas Schneider and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_winlock
(3) in getai : getai: host 192.168.1.190 matches an IP address
(2) in ssh_socket_connect : ssh_socket_connect: Nonblocking connection socket: 2132
(2) in ssh_connect : ssh_connect: Socket connecting, now waiting for the callbacks to work
(3) in ssh_connect : ssh_connect: Actual timeout : 10000
(1) in ssh_connect : ssh_connect: Timeout connecting to 192.168.1.190
(3) in ssh_connect : ssh_connect: current state : 9

The machine where above code does not work can successfully ping 192.168.1.190, a connection to the server can be established using Putty and FileZilla, it's just the code using libssh that does not work.


Does anyone have any ideas what can be tried to resolve the issue?

Thomas Flinkow
  • 4,845
  • 5
  • 29
  • 65
  • So, the code (should perhaps be a [mcve]) works fine with some machines but not others. What is the difference between the machines? – Ulrich Eckhardt Feb 28 '22 at 10:21
  • @UlrichEckhardt There does not seem to be a discernible pattern: some machines where it works use Windows 11, some use Windows 10, the machine where it does not work uses Windows 11. All machines use the same VPN configuration (and all machines can ping the server). It seems that the firewalls of all machines are also configured the same. Do you have an idea of what difference there could be (that matters enough to explain the described behavior)? – Thomas Flinkow Feb 28 '22 at 11:01

0 Answers0