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

Incompability with libssh 0.10.6 #15522

Closed
henrikjehgmti opened this issue Nov 8, 2024 · 3 comments
Closed

Incompability with libssh 0.10.6 #15522

henrikjehgmti opened this issue Nov 8, 2024 · 3 comments
Labels

Comments

@henrikjehgmti
Copy link

henrikjehgmti commented Nov 8, 2024

I did this

I have:

curl --version

curl 8.10.1 (arm-unknown-none) libcurl/8.10.1 OpenSSL/3.0.15 zlib/1.2.11 libssh/0.10.6/openssl/zlib
Release-Date: 2024-09-18

I want to do a sftp download from an IPv6 server, but get the following output:
curl -u test:password -k sftp://[fd4d:5449:7400:111:626d:3cff:fedf:4d39]/file -o file
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (2) Could not set remote host

I analyzed the LibSsh code, and found that LibSsh was not happy about the host name due to missing brackets around the IPv6 address.

I did a workaround in curl/src/lib/vssh/libssh.c to reinsert the brackets.
curl_ip6_libssh0_10_6.patch

Index: ../sw_apps_linux/curl/src/lib/vssh/libssh.c
===================================================================
--- ../sw_apps_linux/curl/src/lib/vssh/libssh.c (revision 5373)
+++ ../sw_apps_linux/curl/src/lib/vssh/libssh.c (working copy)
@@ -2186,7 +2186,22 @@
     return CURLE_FAILED_INIT;
   }

+  struct in6_addr ip6result;
+
+  if (inet_pton(AF_INET6, conn->host.name, &ip6result) == 1) // success!
+  {
+      char newIp6[64];
+      sprintf(newIp6, "[%s]", conn->host.name);
+      rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, newIp6);
+  }
+  else
+  {
+      rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name);
+  }

I ended up doing it here as I fear that host.name is used for e.g. TLS name verification, but I could not see if that was the case.

Do you already have a better solution for this, or can you use it (it should be under LIBSSH version flags perhaps)? I was not able to find any existing bugs that mentions this configuration, so I hope that this is not a duplicate.

I expected the following

No response

curl/libcurl version

curl 8.10.1 (arm-unknown-none) libcurl/8.10.1 OpenSSL/3.0.15 zlib/1.2.11 libssh/0.10.6/openssl/zlib

operating system

Linux mti-ru 5.15.0 #79 SMP PREEMPT Fri Jul 5 14:00:08 CEST 2024 aarch64 GNU/Linux

@bagder bagder added the SCP/SFTP label Nov 8, 2024
@bagder
Copy link
Member

bagder commented Nov 8, 2024

libssh does not document this. I filed an issue: https://gitlab.com/libssh/libssh-mirror/-/issues/281

bagder added a commit that referenced this issue Nov 8, 2024
Reported-by: henrikjehgmti on github
Fixes #15522
@bagder
Copy link
Member

bagder commented Nov 8, 2024

@henrikjehgmti I made #15524 based on your patch but just a tad bit different.

@bagder bagder closed this as completed in 93c65c0 Nov 9, 2024
@henrikjehgmti
Copy link
Author

Thank you very much, and thanks a lot for the quick turnaround time.

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

Successfully merging a pull request may close this issue.

2 participants