Bug 2091512

Summary: curl prints unexpected messages when using sftp URLs and LogLevel is set
Product: Red Hat Enterprise Linux 8 Reporter: Daniel Reynolds <dareynol>
Component: libsshAssignee: Norbert Pócs <npocs>
Status: CLOSED ERRATA QA Contact: Stanislav Zidek <szidek>
Severity: low Docs Contact:
Priority: low    
Version: 8.6CC: ansasaki, asosedki, jafiala, kdudka, npocs
Target Milestone: rcKeywords: Reopened, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libssh-0.9.6-4.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2132407 (view as bug list) Environment:
Last Closed: 2023-05-16 09:10:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2132407    

Description Daniel Reynolds 2022-05-30 07:51:27 UTC
Description of problem:
curl prints unexpected messages when using sftp URLs and LogLevel is set


Version-Release number of selected component (if applicable):
- curl-7.61.1-22.el8.x86_64


How reproducible:
Always


Steps to Reproduce:

1. Add LogLevel to `/etc/ssh/ssh_config`

    Similar errors shown for FATAL, ERROR, INFO

        LogLevel FATAL

2. Fetch file using curl

        [dareynol@localhost ~]$ curl -sk -u dareynol sftp://localhost/home/dareynol/test-file test-file.out

Actual results:

Enter host password for user 'dareynol':
[2022/05/30 03:47:59.356338, 1] ssh_config_parse_line:  line 3: Unsupported Match keyword 'final', skipping
[2022/05/30 03:47:59.356376, 1] ssh_config_parse_line:  Unknown option: GSSAPIKexAlgorithms, line: 3
[2022/05/30 03:47:59.356381, 1] ssh_config_parse_line:  Unknown option: CASignatureAlgorithms, line: 6
[2022/05/30 03:47:59.356397, 1] socket_callback_connected:  Socket connection callback: 1 (0)
[2022/05/30 03:47:59.356490, 1] ssh_known_hosts_read_entries:  Failed to open the known_hosts file '/etc/ssh/ssh_known_hosts': No such file or directory
[2022/05/30 03:47:59.365865, 1] ssh_packet_userauth_failure:  Access denied for 'none'. Authentication that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
[2022/05/30 03:47:59.551241, 1] ssh_pki_import_pubkey_file:  Error opening /home/dareynol/.ssh/id_ed25519.pub: No such file or directory
[2022/05/30 03:47:59.551273, 1] ssh_pki_import_privkey_file:  Error opening /home/dareynol/.ssh/id_ed25519: No such file or directory
[2022/05/30 03:47:59.551278, 1] ssh_pki_import_pubkey_file:  Error opening /home/dareynol/.ssh/id_ecdsa.pub: No such file or directory
[2022/05/30 03:47:59.551281, 1] ssh_pki_import_privkey_file:  Error opening /home/dareynol/.ssh/id_ecdsa: No such file or directory
[2022/05/30 03:47:59.551285, 1] ssh_pki_import_pubkey_file:  Error opening /home/dareynol/.ssh/id_rsa.pub: No such file or directory
[2022/05/30 03:47:59.551289, 1] ssh_pki_import_privkey_file:  Error opening /home/dareynol/.ssh/id_rsa: No such file or directory
[2022/05/30 03:47:59.551293, 1] ssh_pki_import_pubkey_file:  Error opening /home/dareynol/.ssh/id_dsa.pub: No such file or directory
[2022/05/30 03:47:59.551297, 1] ssh_pki_import_privkey_file:  Error opening /home/dareynol/.ssh/id_dsa: No such file or directory
[2022/05/30 03:47:59.573869, 1] ssh_packet_global_request:  Invalid SSH_MSG_GLOBAL_REQUEST packet


Expected results:

[dareynol@rhel7 ~]$ curl -sk -u dareynol sftp://localhost/home/dareynol/test-file -o test-file.out 
Enter host password for user 'dareynol':
[dareynol@rhel7 ~]$ q


Additional info:

RHEL 7 works as expected.
- rpm version curl-7.29.0-59.el7_9.1.x86_64

Comment 1 Kamil Dudka 2022-05-30 08:01:13 UTC
This seems to be printed by libssh, which libcurl uses for the SSH layer.  I am switching the component accordingly.

Comment 2 Norbert Pócs 2022-06-06 16:41:37 UTC
Hi Daniel,

Can you please clarify the bug; is curl failing with set loglevel in libssh config file?

Comment 3 Kamil Dudka 2022-06-06 17:16:12 UTC
Not that I was asked but I believe the info is already available in comment #0:

- LogLevel is set in `/etc/ssh/ssh_config`, which is installed by openssh-clients

- curl is not failing, it just prints unexpected messages

Comment 6 Kamil Dudka 2022-06-07 11:56:13 UTC
The ssh_config(5) man page says it is OpenSSH client configuration file though.  In particular, the documentation of LogLevel says:

    "Gives the verbosity level that is used when logging messages from ssh(1)."

I do not think it works as documented.

Comment 7 Norbert Pócs 2022-06-07 12:08:16 UTC
(In reply to Kamil Dudka from comment #6)
> The ssh_config(5) man page says it is OpenSSH client configuration file
> though.  In particular, the documentation of LogLevel says:
> 
>     "Gives the verbosity level that is used when logging messages from
> ssh(1)."
> 
> I do not think it works as documented.

Libssh in contrast to OpenSSH does not provide any client application (as ssh[1]) and uses LogLevel
(and overall the configuration file) for any connection being made as a client. (function ssh_connect)

Comment 8 Kamil Dudka 2022-06-07 12:40:51 UTC
Where is it documented?  I can see no mention of `/etc/ssh/ssh_config` in libssh documentation, even with libssh-devel installed.

Comment 9 Kamil Dudka 2022-06-07 13:12:22 UTC
Apart from the missing documentation, the implementation in libssh [1] is totally incompatible with OpenSSH:

(1) OpenSSH sets default LogLevel to INFO.  So setting LogLevel to INFO should not change the behavior.  libssh defaults to QUIET.

(2) Setting LogLevel to FATAL or ERROR causes OpenSSH to print fewer diagnostic messages, which quite opposite to what libssh does.

So the changes to a config file of OpenSSH lead to completely unexpected changes in the behavior of curl.  This needs to be fixed.

[1] https://git.libssh.org/projects/libssh.git/tree/src/bind_config.c?h=libssh-0.9.6#n412

Comment 11 Norbert Pócs 2022-06-07 13:29:43 UTC
I will add it to the documentation too.

Comment 24 errata-xmlrpc 2023-05-16 09:10:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (libssh bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:3008