curl icon indicating copy to clipboard operation
curl copied to clipboard

curl with sftp does not honor Port in ssh config file

Open Ben-Voris opened this issue 3 years ago • 1 comments

I did this

I must connect to a system running ssh on a non-standard port. Passing sftp://user@host-name:port to curl works.

But I have a number of makefiles that get the host in an env variable. I.e., the command really is sftp://$(USER)@$(HOST).

I could put the port in the HOST env variable, but that same env variable is expanded and passed to ssh which requires that the port be passed with the '-p' option.

I put the port number in ~/.ssh/config like so:

Host host-name
        Port 2345

"OpenSSH_9.0p1, OpenSSL 1.1.1q 5 Jul 2022" and "OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022" honor this but curl does not.

I expected the following

curl to honor the Port value from ssh config.

curl/libcurl version

Cygwin

curl 7.84.0 (x86_64-pc-cygwin) libcurl/7.84.0

OpenSSL/1.1.1q zlib/1.2.12 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.3 libpsl/0.21.1 (+libidn2/2.3.1) libssh2/1.10.0 nghttp2/1.48.0 libgsasl/1.8.0 OpenLDAP/2.6.3 Release-Date: 2022-06-27 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS brotli Debug gsasl GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP TrackMemory UnixSockets zstd

Ubuntu

curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0

OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.12 Release-Date: 2022-01-05 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets zstd

operating system

CYGWIN_NT-10.0-19042 LNCECL5HRV 3.3.5-341.x86_64 2022-05-13 12:27 UTC x86_64 Cygwin under Windows 10.

And

Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Ben-Voris avatar Aug 10 '22 01:08 Ben-Voris

curl doesn't read OpenSSH config files; it would only be able to support a fraction of the possible options even if it did.

dfandrich avatar Aug 10 '22 04:08 dfandrich

That config file is best left for OpenSSH to read, parse and understand. curl simply cannot parse that.

bagder avatar Aug 10 '22 12:08 bagder

Too bad. I had hoped that because curl libssh and libssh uses OpenSSH, it would honor the config file and so allow curl to behave like OpenSSH clients.

Knowing that curl ignores the SSH config files also explains why I can't use it with systems that disconnect when presented with certain types of keys.

Thank you for your time.

Ben-Voris avatar Aug 10 '22 17:08 Ben-Voris

@bagder Would it make sense to have an option to allow this? I think @Ben-Voris has a significant usability point here. Many software projects honor ~/.ssh/config. An option like --use-ssh-config might be something of value. I might be convinced to contribute something like that, time permitting.

rsbeckerca avatar Aug 10 '22 19:08 rsbeckerca

@bagder Would it make sense to have an option to allow this? I think @Ben-Voris has a significant usability point here. Many software projects honor ~/.ssh/config. An option like --use-ssh-config might be something of value. I might be convinced to contribute something like that, time permitting.

Usually, the curl mailing list is the right place for discussions of these kind.

cvengler avatar Aug 10 '22 20:08 cvengler

I know libssh has (partlal?) support for that file, but I don't know how well it works and that is just one of the three SSH backends curl supports. I would entertain a discussion around why, if and how this could be done - but as @emilengler says, this issue is not the right place. I would propose using the curl-library mailing list for the widest reach, or perhaps as a "discussion" here on github/curl/curl.

bagder avatar Aug 11 '22 07:08 bagder

@Ben-Voris Please see the discussion on the curl-library distribution list (or email me directly). It would be good if you could chime in on the subject there. BR Randall

rsbeckerca avatar Aug 11 '22 21:08 rsbeckerca