Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Couldn't apply options" on a minimal test case console app #1

Open
nrathaus opened this issue Jun 20, 2019 · 5 comments
Open

"Couldn't apply options" on a minimal test case console app #1

nrathaus opened this issue Jun 20, 2019 · 5 comments
Assignees

Comments

@nrathaus
Copy link

Running a console application with libssh doesn't ssh_connect, rather returns "Couldn't apply options" - which isn't very informative.

Context

I tried to run the following code:

int main()
{
  ssh_session my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    return -1;

  int verbosity = SSH_LOG_PROTOCOL;
  int port = 22;

  int rc = ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "192.168.15.1");
  rc = ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
  rc = ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);

  rc = ssh_connect(my_ssh_session);
  if (rc != SSH_OK)
  {
    fprintf(stderr, "Error connecting to localhost: %s\n",
      ssh_get_error(my_ssh_session));
    exit(-1);
  }

  ssh_free(my_ssh_session);

  return 0;
}

But it returns "Couldn't apply options" error to ssh_connect(), all the ssh_options_set work (return a value of 0)

Expected Behavior

Connect to the SSH server

Actual Behavior

Returns an error

Steps to Reproduce

  1. Take the above code
  2. Compile it as a Console Application, x86, Multibyte (I also tried Unicode)
  3. Run

Your Environment

  • Version Used: 0.8.7
  • Operating System and Version: Windows 10 RS5 (1903)
  • Compiler and Version(s): Visual Studio 2015

Possible Fix

:Shrug:

@Sibras
Copy link
Member

Sibras commented Jun 27, 2019

Have you tried other libssh binaries such as the one from vcpkg?
If its an issue with the binaries provided here then i can help but if its an issue with libssh itself then you should try the libssh upstream developers instead.

@nrathaus
Copy link
Author

nrathaus commented Jun 27, 2019 via email

@Sibras
Copy link
Member

Sibras commented Jun 30, 2019

There is new 0.9.0 version of libssh now available. See if that fixes your issues.

@Sibras Sibras self-assigned this Sep 12, 2019
@ironxu
Copy link

ironxu commented Feb 18, 2023

helo The current version 0.10.4 still has this problem

@ironxu
Copy link

ironxu commented Feb 19, 2023

[2023/02/19 12:41:36.185525, 2] ssh_connect: libssh 0.10.4 (c) 2003-2022 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
[2023/02/19 12:41:36.189525, 3] getai: host 192.168.199.130 matches an IP address
[2023/02/19 12:41:36.190525, 2] ssh_socket_connect: Nonblocking connection socket: 664
[2023/02/19 12:41:36.190525, 2] ssh_connect: Socket connecting, now waiting for the callbacks to work
[2023/02/19 12:41:36.190525, 3] ssh_connect: Actual timeout : 10000
[2023/02/19 12:41:36.191525, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLOUT ), out buffer 0
[2023/02/19 12:41:36.191525, 3] ssh_socket_pollcallback: Received POLLOUT in connecting state
[2023/02/19 12:41:36.191525, 1] socket_callback_connected: Socket connection callback: 1 (0)
[2023/02/19 12:41:36.191525, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2023/02/19 12:41:36.191525, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLOUT ), out buffer 0
[2023/02/19 12:41:36.207851, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLIN ), out buffer 0
[2023/02/19 12:41:36.207851, 3] callback_receive_banner: Received banner: SSH-2.0-OpenSSH_7.4
[2023/02/19 12:41:36.207851, 2] ssh_client_connection_callback: SSH server banner: SSH-2.0-OpenSSH_7.4
[2023/02/19 12:41:36.207851, 2] ssh_analyze_banner: Analyzing banner: SSH-2.0-OpenSSH_7.4
[2023/02/19 12:41:36.207851, 2] ssh_analyze_banner: We are talking to an OpenSSH server version: 7.4 (70400)
[2023/02/19 12:41:36.237569, 3] 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"
[2023/02/19 12:41:36.239581, 1] ssh_known_hosts_read_entries: Failed to open the known_hosts file '/etc/ssh/ssh_known_hosts': No such file or directory
[2023/02/19 12:41:36.239581, 3] ssh_client_select_hostkeys: No key found in known_hosts; changing host key method to "ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256"
[2023/02/19 12:41:36.239581, 4] ssh_list_kex: kex algos: curve25519-sha256,[email protected],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,ext-info-c
[2023/02/19 12:41:36.239581, 4] ssh_list_kex: server host key algo: ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256
[2023/02/19 12:41:36.239581, 4] ssh_list_kex: encryption client->server: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr,
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: encryption server->client: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr,
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: mac algo client->server: [email protected],[email protected],hmac-sha2-256,hmac-sha2-512
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: mac algo server->client: [email protected],[email protected],hmac-sha2-256,hmac-sha2-512
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: compression algo client->server: none,[email protected],zlib
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: compression algo server->client: none,[email protected],zlib
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: languages client->server:
[2023/02/19 12:41:36.240581, 4] ssh_list_kex: languages server->client:
[2023/02/19 12:41:36.240581, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2023/02/19 12:41:36.240581, 3] packet_send2: packet: wrote [type=20, len=852, padding_size=7, comp=844, payload=844]
[2023/02/19 12:41:36.240581, 3] ssh_send_kex: SSH_MSG_KEXINIT sent
[2023/02/19 12:41:36.240581, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLOUT ), out buffer 0
[2023/02/19 12:41:36.240581, 4] ssh_socket_pollcallback: sending control flow event
[2023/02/19 12:41:36.240581, 4] ssh_packet_socket_controlflow_callback: sending channel_write_wontblock callback
[2023/02/19 12:41:36.241851, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLIN ), out buffer 0
[2023/02/19 12:41:36.241851, 3] ssh_packet_socket_callback: packet: read type 20 [len=1276,padding=10,comp=1265,payload=1265]
[2023/02/19 12:41:36.241851, 3] ssh_packet_process: Dispatching handler for packet type 20
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: kex algos: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: server host key algo: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: encryption client->server: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: encryption server->client: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: mac algo client->server: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: mac algo server->client: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: compression algo client->server: none,[email protected]
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: compression algo server->client: none,[email protected]
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: languages client->server:
[2023/02/19 12:41:36.241851, 4] ssh_list_kex: languages server->client:
[2023/02/19 12:41:36.241851, 2] ssh_kex_select_methods: Negotiated curve25519-sha256,ssh-ed25519,[email protected],[email protected],aead-poly1305,aead-poly1305,none,none,,
[2023/02/19 12:41:36.243032, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2023/02/19 12:41:36.243032, 3] packet_send2: packet: wrote [type=30, len=44, padding_size=6, comp=37, payload=37]
[2023/02/19 12:41:36.243032, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLOUT ), out buffer 0
[2023/02/19 12:41:36.243032, 4] ssh_socket_pollcallback: sending control flow event
[2023/02/19 12:41:36.243032, 4] ssh_packet_socket_controlflow_callback: sending channel_write_wontblock callback
[2023/02/19 12:41:36.253666, 4] ssh_socket_pollcallback: Poll callback on socket 664 (POLLIN ), out buffer 0
[2023/02/19 12:41:36.253666, 3] ssh_packet_socket_callback: packet: read type 31 [len=188,padding=8,comp=179,payload=179]
[2023/02/19 12:41:36.253666, 3] ssh_packet_process: Dispatching handler for packet type 31
[2023/02/19 12:41:36.253666, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2023/02/19 12:41:36.253666, 3] packet_send2: packet: wrote [type=21, len=12, padding_size=10, comp=1, payload=1]
[2023/02/19 12:41:36.255172, 4] ssh_packet_set_newkeys: called, direction = OUT
[2023/02/19 12:41:36.255172, 3] crypt_set_algorithms2: Set output algorithm to [email protected]
[2023/02/19 12:41:36.255172, 3] crypt_set_algorithms2: Set HMAC output algorithm to aead-poly1305
[2023/02/19 12:41:36.255172, 3] crypt_set_algorithms2: Set input algorithm to [email protected]
[2023/02/19 12:41:36.256174, 3] crypt_set_algorithms2: Set HMAC input algorithm to aead-poly1305
[2023/02/19 12:41:36.256174, 2] ssh_init_rekey_state: Set rekey after 134217728 blocks
[2023/02/19 12:41:36.256174, 2] ssh_init_rekey_state: Set rekey after 134217728 blocks
[2023/02/19 12:41:36.256174, 2] ssh_packet_client_curve25519_reply: SSH_MSG_NEWKEYS sent
[2023/02/19 12:41:36.257268, 3] ssh_packet_socket_callback: Processing 100 bytes left in socket buffer
[2023/02/19 12:41:36.257268, 3] ssh_packet_socket_callback: packet: read type 21 [len=12,padding=10,comp=1,payload=1]
[2023/02/19 12:41:36.257268, 3] ssh_packet_process: Dispatching handler for packet type 21
[2023/02/19 12:41:36.257268, 2] ssh_packet_newkeys: Received SSH_MSG_NEWKEYS
[2023/02/19 12:41:36.257268, 4] ssh_pki_signature_verify: Going to verify a ssh-ed25519 type signature
[2023/02/19 12:41:36.260323, 4] pki_verify_data_signature: ED25519 error: Signature invalid

[2023/02/19 12:41:36.260323, 3] ssh_packet_socket_callback: Processing 84 bytes left in socket buffer
[2023/02/19 12:41:36.260323, 3] ssh_packet_socket_callback: Packet: processed 0 bytes
[2023/02/19 12:41:36.260323, 3] ssh_packet_socket_callback: Packet: processed 0 bytes
[2023/02/19 12:41:36.260323, 3] ssh_connect: current state : 9
Error connecting to localhost:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants