Page MenuHomePhabricator

Bug: sftp_setstat broken in release build of libssh 0.9.5 provided by vcpkg
Open, Needs TriagePublic

Description

The following code compiled using Visual Studio 2019 and libssh 0.9.5 built by vcpkg results in testFile.txt being created and having the correct last write time in debug build. However, with release build last write time is not set correctly, but rather remains in current time.

#include <iostream>
#include <libssh/libsshpp.hpp>
#include <libssh/sftp.h>
#include <fcntl.h>

int main()
{
   std::cout << "Host name: ";
   std::string hostName;
   std::getline(std::cin, hostName);

   std::cout << "User name: ";
   std::string userName;
   std::getline(std::cin, userName);

   ssh::Session sshSession;
   sshSession.setOption(SSH_OPTIONS_HOST, hostName.c_str());
   sshSession.setOption(SSH_OPTIONS_USER, userName.c_str());
   sshSession.setOption(SSH_OPTIONS_PORT, 22);
   sshSession.setOption(SSH_OPTIONS_LOG_VERBOSITY, SSH_LOG_FUNCTIONS);

   sshSession.connect();
   std::cout << "ssh version: " << sshSession.getVersion() << std::endl;

   switch (sshSession.isServerKnown())
   {
   case SSH_KNOWN_HOSTS_OK:
      std::cout << "Known hosts OK";
      break;
   case SSH_KNOWN_HOSTS_CHANGED:
      std::cout << "Host key for server changed. For security reasons, connection will be stopped.";
      return -1;
   case SSH_KNOWN_HOSTS_OTHER:
      std::cout << "The host key for this server was not found but an other type of key exists.\n"
         "An attacker might change the default server key to confuse your client into thinking the key does not exist";
      return -1;
   case SSH_KNOWN_HOSTS_NOT_FOUND:
      std::cout << "Could not find known host file.\n"
         "If you accept the host key here, the file will be automatically created.";
      /* FALL THROUGH to SSH_SERVER_NOT_KNOWN behavior */
   case SSH_KNOWN_HOSTS_UNKNOWN:
      std::cout << "The server is unknown. Do you trust the host key?";
      break;
   case SSH_KNOWN_HOSTS_ERROR:
      std::cout << std::string("Error ") + sshSession.getError();
      return -1;
   }

   std::cout << std::endl;

   bool authSuccess = false;

   switch (sshSession.userauthPublickeyAuto())
   {
   case SSH_AUTH_SUCCESS:
      std::cout << "Authentication successful";
      authSuccess = true;
      break;
   case SSH_AUTH_PARTIAL:
      std::cout << "Authentication partial";
      break;
   case SSH_AUTH_DENIED:
      std::cout << "Authentication denied";
      break;
   }

   std::cout << std::endl;

   if (!authSuccess)
   {
      std::cout << "Password: ";
      std::string password;
      std::getline(std::cin, password);

      switch (sshSession.userauthPassword(password.c_str()))
      {
      case SSH_AUTH_SUCCESS:
         std::cout << "Authentication successful";
         break;
      case SSH_AUTH_PARTIAL:
         std::cout << "Authentication partial";
         break;
      case SSH_AUTH_DENIED:
         std::cout << "Authentication denied";
         return -1;
      }

      std::cout << std::endl;
   }

   const char* remoteFilePath = "testFile.txt";

   sftp_session sftpSession = sftp_new(sshSession.getCSession());
   if (sftpSession == nullptr)
   {
      std::cerr << "Could not create sftp session";
      return -1;
   }

   if (sftp_init(sftpSession) != SSH_OK)
   {
      std::cerr << "Could not init sftp session";
      sftp_free(sftpSession);
      return -1;
   }

   // Write only, create if doesn't exist yet, binary mode, truncate
   const int accessType = O_WRONLY | O_CREAT | O_BINARY | O_TRUNC;

   sftp_file file = sftp_open(sftpSession, remoteFilePath, accessType, 0);
   if (file == nullptr)
   {
      std::cerr << "Can't open remote file for writing: " << sshSession.getError() << std::endl;
      sftp_free(sftpSession);
      return -1;
   }

   std::cout << "Calling sftp_netstat" << std::endl;

   sftp_attributes_struct newRemoteFileAttributes;
   newRemoteFileAttributes.mtime = 1501106638;
   if (sftp_setstat(sftpSession, remoteFilePath, &newRemoteFileAttributes) != SSH_OK)
   {
      std::cerr << "Can't set attributes (last write time) for remote file: " << sshSession.getError() << std::endl;
      sftp_close(file);
      sftp_free(sftpSession);
      return -1;
   }

   std::cout << "Successfully called sftp_netstat" << std::endl;
   sftp_close(file);
   sftp_free(sftpSession);

   return 0;
}

The host that I'm connecting to is a Windows 10 machine running OpenSSH server (sshd.exe) version 7.7.2.3.

I have removed the timestamps from the following outputs for easier comparison.

Debug build (works correctly) prints the following after I have given host name and user name:

ssh_connect:  libssh 0.9.5 (c) 2003-2019 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
ssh_socket_connect:  Nonblocking connection socket: 680
ssh_connect:  Socket connecting, now waiting for the callbacks to work
ssh_connect:  Actual timeout : 10000
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  Received POLLOUT in connecting state
socket_callback_connected:  Socket connection callback: 1 (0)
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
callback_receive_banner:  Received banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_client_connection_callback:  SSH server banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_analyze_banner:  Analyzing banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_client_select_hostkeys:  Order of wanted host keys: "ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa"
ssh_known_hosts_read_entries:  Failed to open the known_hosts file '/etc/ssh/ssh_known_hosts': No such file or directory
ssh_client_select_hostkeys:  Algorithms found in known_hosts files: "ecdsa-sha2-nistp256"
ssh_client_select_hostkeys:  Changing host key method to "ecdsa-sha2-nistp256,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256,ssh-rsa"
ssh_list_kex:  kex algos: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
ssh_list_kex:  server host key algo: ecdsa-sha2-nistp256,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256,ssh-rsa
ssh_list_kex:  encryption client->server: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
ssh_list_kex:  encryption server->client: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
ssh_list_kex:  mac algo client->server: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  mac algo server->client: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  compression algo client->server: none
ssh_list_kex:  compression algo server->client: none
ssh_list_kex:  languages client->server:
ssh_list_kex:  languages server->client:
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=20, len=964, padding_size=6, comp=957, payload=957]
ssh_send_kex:  SSH_MSG_KEXINIT sent
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 20 [len=1044,padding=8,comp=1035,payload=1035]
ssh_packet_process:  Dispatching handler for packet type 20
ssh_list_kex:  kex algos: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
ssh_list_kex:  server host key algo: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
ssh_list_kex:  encryption client->server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
ssh_list_kex:  encryption server->client: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
ssh_list_kex:  mac algo client->server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  mac algo server->client: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  compression algo client->server: none
ssh_list_kex:  compression algo server->client: none
ssh_list_kex:  languages client->server:
ssh_list_kex:  languages server->client:
ssh_kex_select_methods:  Negotiated curve25519-sha256,ecdsa-sha2-nistp256,aes256-gcm@openssh.com,aes256-gcm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-256-etm@openssh.com,none,none,,
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=30, len=44, padding_size=6, comp=37, payload=37]
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 31 [len=260,padding=10,comp=249,payload=249]
ssh_packet_process:  Dispatching handler for packet type 31
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=21, len=12, padding_size=10, comp=1, payload=1]
ssh_packet_set_newkeys:  called, direction = OUT
crypt_set_algorithms2:  Set output algorithm to aes256-gcm@openssh.com
crypt_set_algorithms2:  Set HMAC output algorithm to aead-gcm
crypt_set_algorithms2:  Set input algorithm to aes256-gcm@openssh.com
crypt_set_algorithms2:  Set HMAC input algorithm to aead-gcm
ssh_init_rekey_state:  Set rekey after 4294967296 blocks
ssh_init_rekey_state:  Set rekey after 4294967296 blocks
ssh_packet_client_curve25519_reply:  SSH_MSG_NEWKEYS sent
ssh_packet_socket_callback:  Processing 196 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 21 [len=12,padding=10,comp=1,payload=1]
ssh_packet_process:  Dispatching handler for packet type 21
ssh_packet_newkeys:  Received SSH_MSG_NEWKEYS
ssh_pki_signature_verify:  Going to verify a ecdsa-sha2-nistp256 type signature
ssh_packet_newkeys:  Signature verified and valid
ssh_packet_set_newkeys:  called, direction = IN
ssh_packet_socket_callback:  Processing 180 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 7 [len=160,padding=18,comp=141,payload=141]
ssh_packet_process:  Dispatching handler for packet type 7
ssh_packet_ext_info:  Received SSH_MSG_EXT_INFO
ssh_packet_ext_info:  Follows 1 extensions
ssh_packet_ext_info:  Extension: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
ssh_connect:  current state : 7
ssh version: 2
Known hosts OK
ssh_userauth_publickey_auto:  Trying to authenticate with <key file path>
ssh_key_algorithm_allowed:  Checking ssh-ed25519 with list <ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
packet_send2:  packet: wrote [type=5, len=32, padding_size=14, comp=17, payload=17]
ssh_service_request:  Sent SSH_MSG_SERVICE_REQUEST (service ssh-userauth)
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 52
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 6 [len=32,padding=14,comp=17,payload=17]
ssh_packet_process:  Dispatching handler for packet type 6
ssh_packet_service_accept:  Received SSH_MSG_SERVICE_ACCEPT
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=50, len=128, padding_size=10, comp=117, payload=117]
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 60 [len=80,padding=8,comp=71,payload=71]
ssh_packet_process:  Dispatching handler for packet type 60
ssh_packet_userauth_pk_ok:  Received SSH_USERAUTH_PK_OK/INFO_REQUEST/GSSAPI_RESPONSE
ssh_packet_userauth_pk_ok:  Assuming SSH_USERAUTH_PK_OK
ssh_pki_import_privkey_base64:  Trying to decode privkey passphrase=false
ssh_pki_openssh_import:  Opening OpenSSH private key: ciphername: none, kdf: none, nkeys: 1
ssh_key_algorithm_allowed:  Checking ssh-ed25519 with list <ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=50, len=224, padding_size=19, comp=204, payload=204]
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 52 [len=16,padding=14,comp=1,payload=1]
ssh_packet_process:  Dispatching handler for packet type 52
ssh_packet_userauth_success:  Authentication successful
ssh_packet_userauth_success:  Received SSH_USERAUTH_SUCCESS
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=20, in_blocks=13
ssh_userauth_publickey_auto:  Successfully authenticated using <key file path>
Authentication successful
channel_open:  Creating a channel 43 with 64000 window and 32768 max packet
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=14
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=90, len=32, padding_size=7, comp=24, payload=24]
channel_open:  Sent a SSH_MSG_CHANNEL_OPEN type session for channel 43
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 80 [len=480,padding=4,comp=475,payload=475]
ssh_packet_process:  Dispatching handler for packet type 80
ssh_packet_global_request:  Received SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_global_request:  UNKNOWN SSH_MSG_GLOBAL_REQUEST hostkeys-00@openssh.com, want_reply = 0
ssh_packet_global_request:  The requester doesn't want to know the request failed!
ssh_packet_global_request:  Invalid SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=42
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 91
ssh_packet_channel_open_conf:  Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION
ssh_packet_channel_open_conf:  Received a CHANNEL_OPEN_CONFIRMATION for channel 43:0
ssh_packet_channel_open_conf:  Remote window : 0, maxpacket : 32768
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=43
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=44
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=98, len=32, padding_size=4, comp=27, payload=27]
channel_request:  Sent a SSH_MSG_CHANNEL_REQUEST subsystem
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 93 [len=16,padding=6,comp=9,payload=9]
ssh_packet_process:  Dispatching handler for packet type 93
channel_rcv_change_window:  Adding 2097152 bytes to channel (43:0) (from 0 bytes)
ssh_packet_socket_callback:  Processing 36 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 99 [len=16,padding=10,comp=5,payload=5]
ssh_packet_process:  Dispatching handler for packet type 99
ssh_packet_channel_success:  Received SSH_CHANNEL_SUCCESS on channel (43:0)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=43
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=43
channel_request:  Channel request subsystem success
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=44
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=32, padding_size=13, comp=18, payload=18]
channel_write_common:  channel_write wrote 9 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 64000
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 94 [len=176,padding=12,comp=163,payload=163]
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 154 bytes data in 0 (local win=64000 remote win=2097143)
channel_default_bufferize:  placing 154 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=63846 remote win=2097143)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=53
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=93, len=16, padding_size=6, comp=9, payload=9]
grow_window:  growing window (channel 43:0) to 1280000 bytes
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=53
ssh_channel_read_timeout:  Read (1) buffered : 150 bytes. Window: 1280000
ssh_channel_read_timeout:  Read (149) buffered : 149 bytes. Window: 1280000
sftp_init:  SFTP server version 3
sftp_init:  SFTP server extension: posix-rename@openssh.com, version: 1
sftp_init:  SFTP server extension: statvfs@openssh.com, version: 2
sftp_init:  SFTP server extension: fstatvfs@openssh.com, version: 2
sftp_init:  SFTP server extension: hardlink@openssh.com, version: 1
sftp_init:  SFTP server extension: fsync@openssh.com, version: 1
sftp_open:  Opening file testFile.txt with sftp flags 1a
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=25, in_blocks=55
packet_send2:  packet: wrote [type=94, len=64, padding_size=17, comp=46, payload=46]
channel_write_common:  channel_write wrote 37 bytes
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 84
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1280000
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 94 [len=32,padding=5,comp=26,payload=26]
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 17 bytes data in 0 (local win=1280000 remote win=2097106)
channel_default_bufferize:  placing 17 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279983 remote win=2097106)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=25, in_blocks=54
ssh_channel_read_timeout:  Read (1) buffered : 13 bytes. Window: 1279983
ssh_channel_read_timeout:  Read (12) buffered : 12 bytes. Window: 1279983
sftp_get_message:  Packet with id 1 type 102
sftp_enqueue:  Queued msg id 1 type 102
sftp_dequeue:  Dequeued msg id 1 type 102
Calling sftp_netstat
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=28, in_blocks=57
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=64, padding_size=13, comp=50, payload=50]
channel_write_common:  channel_write wrote 41 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1279983
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 28 bytes data in 0 (local win=1279983 remote win=2097065)
channel_default_bufferize:  placing 28 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279955 remote win=2097065)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=28, in_blocks=56
ssh_channel_read_timeout:  Read (1) buffered : 24 bytes. Window: 1279955
ssh_channel_read_timeout:  Read (23) buffered : 23 bytes. Window: 1279955
sftp_get_message:  Packet with id 2 type 101
sftp_enqueue:  Queued msg id 2 type 101
sftp_dequeue:  Dequeued msg id 2 type 101
Successfully called sftp_netstat
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=57
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=32, padding_size=5, comp=26, payload=26]
channel_write_common:  channel_write wrote 17 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1279955
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 28 bytes data in 0 (local win=1279955 remote win=2097048)
channel_default_bufferize:  placing 28 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279927 remote win=2097048)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
ssh_channel_read_timeout:  Read (1) buffered : 24 bytes. Window: 1279927
ssh_channel_read_timeout:  Read (23) buffered : 23 bytes. Window: 1279927
sftp_get_message:  Packet with id 3 type 101
sftp_enqueue:  Queued msg id 3 type 101
sftp_dequeue:  Dequeued msg id 3 type 101
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=96, len=16, padding_size=10, comp=5, payload=5]
ssh_channel_send_eof:  Sent a EOF on client channel (43:0)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
packet_send2:  packet: wrote [type=97, len=16, padding_size=10, comp=5, payload=5]
ssh_channel_close:  Sent a close on client channel (43:0)
ssh_socket_pollcallback:  Poll callback on socket 680 (POLLOUT ), out buffer 36
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket

Release build (works incorrectly) prints the following after I have given host name and user name:

ssh_connect:  libssh 0.9.5 (c) 2003-2019 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
ssh_socket_connect:  Nonblocking connection socket: 676
ssh_connect:  Socket connecting, now waiting for the callbacks to work
ssh_connect:  Actual timeout : 10000
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  Received POLLOUT in connecting state
socket_callback_connected:  Socket connection callback: 1 (0)
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
callback_receive_banner:  Received banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_client_connection_callback:  SSH server banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_analyze_banner:  Analyzing banner: SSH-2.0-OpenSSH_for_Windows_7.7
ssh_client_select_hostkeys:  Order of wanted host keys: "ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa"
ssh_known_hosts_read_entries:  Failed to open the known_hosts file '/etc/ssh/ssh_known_hosts': No such file or directory
ssh_client_select_hostkeys:  Algorithms found in known_hosts files: "ecdsa-sha2-nistp256"
ssh_client_select_hostkeys:  Changing host key method to "ecdsa-sha2-nistp256,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256,ssh-rsa"
ssh_list_kex:  kex algos: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
ssh_list_kex:  server host key algo: ecdsa-sha2-nistp256,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256,ssh-rsa
ssh_list_kex:  encryption client->server: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
ssh_list_kex:  encryption server->client: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
ssh_list_kex:  mac algo client->server: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  mac algo server->client: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  compression algo client->server: none
ssh_list_kex:  compression algo server->client: none
ssh_list_kex:  languages client->server:
ssh_list_kex:  languages server->client:
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=20, len=964, padding_size=6, comp=957, payload=957]
ssh_send_kex:  SSH_MSG_KEXINIT sent
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 20 [len=1044,padding=8,comp=1035,payload=1035]
ssh_packet_process:  Dispatching handler for packet type 20
ssh_list_kex:  kex algos: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
ssh_list_kex:  server host key algo: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
ssh_list_kex:  encryption client->server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
ssh_list_kex:  encryption server->client: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
ssh_list_kex:  mac algo client->server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  mac algo server->client: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
ssh_list_kex:  compression algo client->server: none
ssh_list_kex:  compression algo server->client: none
ssh_list_kex:  languages client->server:
ssh_list_kex:  languages server->client:
ssh_kex_select_methods:  Negotiated curve25519-sha256,ecdsa-sha2-nistp256,aes256-gcm@openssh.com,aes256-gcm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-256-etm@openssh.com,none,none,,
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=30, len=44, padding_size=6, comp=37, payload=37]
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 31 [len=260,padding=9,comp=250,payload=250]
ssh_packet_process:  Dispatching handler for packet type 31
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=21, len=12, padding_size=10, comp=1, payload=1]
ssh_packet_set_newkeys:  called, direction = OUT
crypt_set_algorithms2:  Set output algorithm to aes256-gcm@openssh.com
crypt_set_algorithms2:  Set HMAC output algorithm to aead-gcm
crypt_set_algorithms2:  Set input algorithm to aes256-gcm@openssh.com
crypt_set_algorithms2:  Set HMAC input algorithm to aead-gcm
ssh_init_rekey_state:  Set rekey after 4294967296 blocks
ssh_init_rekey_state:  Set rekey after 4294967296 blocks
ssh_packet_client_curve25519_reply:  SSH_MSG_NEWKEYS sent
ssh_packet_socket_callback:  Processing 196 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 21 [len=12,padding=10,comp=1,payload=1]
ssh_packet_process:  Dispatching handler for packet type 21
ssh_packet_newkeys:  Received SSH_MSG_NEWKEYS
ssh_pki_signature_verify:  Going to verify a ecdsa-sha2-nistp256 type signature
ssh_packet_newkeys:  Signature verified and valid
ssh_packet_set_newkeys:  called, direction = IN
ssh_packet_socket_callback:  Processing 180 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 7 [len=160,padding=18,comp=141,payload=141]
ssh_packet_process:  Dispatching handler for packet type 7
ssh_packet_ext_info:  Received SSH_MSG_EXT_INFO
ssh_packet_ext_info:  Follows 1 extensions
ssh_packet_ext_info:  Extension: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
ssh_connect:  current state : 7
ssh version: 2
Known hosts OK
ssh_userauth_publickey_auto:  Trying to authenticate with <key file path>
ssh_key_algorithm_allowed:  Checking ssh-ed25519 with list <ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
packet_send2:  packet: wrote [type=5, len=32, padding_size=14, comp=17, payload=17]
ssh_service_request:  Sent SSH_MSG_SERVICE_REQUEST (service ssh-userauth)
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 52
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 6 [len=32,padding=14,comp=17,payload=17]
ssh_packet_process:  Dispatching handler for packet type 6
ssh_packet_service_accept:  Received SSH_MSG_SERVICE_ACCEPT
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=50, len=128, padding_size=10, comp=117, payload=117]
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 60 [len=80,padding=8,comp=71,payload=71]
ssh_packet_process:  Dispatching handler for packet type 60
ssh_packet_userauth_pk_ok:  Received SSH_USERAUTH_PK_OK/INFO_REQUEST/GSSAPI_RESPONSE
ssh_packet_userauth_pk_ok:  Assuming SSH_USERAUTH_PK_OK
ssh_pki_import_privkey_base64:  Trying to decode privkey passphrase=false
ssh_pki_openssh_import:  Opening OpenSSH private key: ciphername: none, kdf: none, nkeys: 1
ssh_key_algorithm_allowed:  Checking ssh-ed25519 with list <ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=50, len=224, padding_size=19, comp=204, payload=204]
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 52 [len=16,padding=14,comp=1,payload=1]
ssh_packet_process:  Dispatching handler for packet type 52
ssh_packet_userauth_success:  Authentication successful
ssh_packet_userauth_success:  Received SSH_USERAUTH_SUCCESS
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=20, in_blocks=13
ssh_userauth_publickey_auto:  Successfully authenticated using <key file path>
Authentication successful
channel_open:  Creating a channel 43 with 64000 window and 32768 max packet
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=14
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=90, len=32, padding_size=7, comp=24, payload=24]
channel_open:  Sent a SSH_MSG_CHANNEL_OPEN type session for channel 43
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 80 [len=480,padding=4,comp=475,payload=475]
ssh_packet_process:  Dispatching handler for packet type 80
ssh_packet_global_request:  Received SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_global_request:  UNKNOWN SSH_MSG_GLOBAL_REQUEST hostkeys-00@openssh.com, want_reply = 0
ssh_packet_global_request:  The requester doesn't want to know the request failed!
ssh_packet_global_request:  Invalid SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=42
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 91
ssh_packet_channel_open_conf:  Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION
ssh_packet_channel_open_conf:  Received a CHANNEL_OPEN_CONFIRMATION for channel 43:0
ssh_packet_channel_open_conf:  Remote window : 0, maxpacket : 32768
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=21, in_blocks=43
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=44
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=98, len=32, padding_size=4, comp=27, payload=27]
channel_request:  Sent a SSH_MSG_CHANNEL_REQUEST subsystem
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 93 [len=16,padding=6,comp=9,payload=9]
ssh_packet_process:  Dispatching handler for packet type 93
channel_rcv_change_window:  Adding 2097152 bytes to channel (43:0) (from 0 bytes)
ssh_packet_socket_callback:  Processing 36 bytes left in socket buffer
ssh_packet_socket_callback:  packet: read type 99 [len=16,padding=10,comp=5,payload=5]
ssh_packet_process:  Dispatching handler for packet type 99
ssh_packet_channel_success:  Received SSH_CHANNEL_SUCCESS on channel (43:0)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=43
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=22, in_blocks=43
channel_request:  Channel request subsystem success
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=44
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=32, padding_size=13, comp=18, payload=18]
channel_write_common:  channel_write wrote 9 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 64000
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 94 [len=176,padding=12,comp=163,payload=163]
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 154 bytes data in 0 (local win=64000 remote win=2097143)
channel_default_bufferize:  placing 154 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=63846 remote win=2097143)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=53
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=93, len=16, padding_size=6, comp=9, payload=9]
grow_window:  growing window (channel 43:0) to 1280000 bytes
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=23, in_blocks=53
ssh_channel_read_timeout:  Read (1) buffered : 150 bytes. Window: 1280000
ssh_channel_read_timeout:  Read (149) buffered : 149 bytes. Window: 1280000
sftp_init:  SFTP server version 3
sftp_init:  SFTP server extension: posix-rename@openssh.com, version: 1
sftp_init:  SFTP server extension: statvfs@openssh.com, version: 2
sftp_init:  SFTP server extension: fstatvfs@openssh.com, version: 2
sftp_init:  SFTP server extension: hardlink@openssh.com, version: 1
sftp_init:  SFTP server extension: fsync@openssh.com, version: 1
sftp_open:  Opening file testFile.txt with sftp flags 1a
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=25, in_blocks=55
packet_send2:  packet: wrote [type=94, len=64, padding_size=17, comp=46, payload=46]
channel_write_common:  channel_write wrote 37 bytes
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 84
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1280000
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_socket_callback:  packet: read type 94 [len=32,padding=5,comp=26,payload=26]
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 17 bytes data in 0 (local win=1280000 remote win=2097106)
channel_default_bufferize:  placing 17 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279983 remote win=2097106)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=25, in_blocks=54
ssh_channel_read_timeout:  Read (1) buffered : 13 bytes. Window: 1279983
ssh_channel_read_timeout:  Read (12) buffered : 12 bytes. Window: 1279983
sftp_get_message:  Packet with id 1 type 102
sftp_enqueue:  Queued msg id 1 type 102
sftp_dequeue:  Dequeued msg id 1 type 102
Calling sftp_netstat
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=28, in_blocks=57
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=64, padding_size=13, comp=50, payload=50]
channel_write_common:  channel_write wrote 41 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1279983
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 28 bytes data in 0 (local win=1279983 remote win=2097065)
channel_default_bufferize:  placing 28 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279955 remote win=2097065)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=28, in_blocks=56
ssh_channel_read_timeout:  Read (1) buffered : 24 bytes. Window: 1279955
ssh_channel_read_timeout:  Read (23) buffered : 23 bytes. Window: 1279955
sftp_get_message:  Packet with id 2 type 101
sftp_enqueue:  Queued msg id 2 type 101
sftp_dequeue:  Dequeued msg id 2 type 101
sftp_setstat:  SFTP server: Failure
Can't set attributes (last write time) for remote file: SFTP server: Failure
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=57
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=94, len=32, padding_size=5, comp=26, payload=26]
channel_write_common:  channel_write wrote 17 bytes
ssh_channel_read_timeout:  Read (4) buffered : 0 bytes. Window: 1279955
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 0
ssh_socket_pollcallback:  sending control flow event
ssh_packet_socket_controlflow_callback:  sending channel_write_wontblock callback
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLIN ), out buffer 0
ssh_packet_process:  Dispatching handler for packet type 94
channel_rcv_data:  Channel receiving 28 bytes data in 0 (local win=1279955 remote win=2097048)
channel_default_bufferize:  placing 28 bytes into channel buffer (stdout)
channel_rcv_data:  Channel windows are now (local win=1279927 remote win=2097048)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
ssh_channel_read_timeout:  Read (1) buffered : 24 bytes. Window: 1279927
ssh_channel_read_timeout:  Read (23) buffered : 23 bytes. Window: 1279927
sftp_get_message:  Packet with id 3 type 101
sftp_enqueue:  Queued msg id 3 type 101
sftp_dequeue:  Dequeued msg id 3 type 101
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket
packet_send2:  packet: wrote [type=96, len=16, padding_size=10, comp=5, payload=5]
ssh_channel_send_eof:  Sent a EOF on client channel (43:0)
ssh_packet_need_rekey:  packet: [data_rekey_needed=0, out_blocks=29, in_blocks=58
packet_send2:  packet: wrote [type=97, len=16, padding_size=10, comp=5, payload=5]
ssh_channel_close:  Sent a close on client channel (43:0)
ssh_socket_pollcallback:  Poll callback on socket 676 (POLLOUT ), out buffer 36
ssh_socket_unbuffered_write:  Enabling POLLOUT for socket

You can see that with release build sftp_setstat fails and prints "sftp_setstat: SFTP server: Failure".

Any ideas where the issue lies? Why does the debug build work correctly but release build not? Is it my own programming error or is the issue in libssh, or just the way vcpkg builds the release version of libssh? Or could the error even be in the OpenSSH server that for some reason?

Event Timeline

lassi created this object with visibility "All Users".
lassi changed the visibility from "All Users" to "Public (No Login Required)".Dec 7 2020, 8:49 AM