Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1901518

Summary: ssh-keygen printing fingerprint issue with Windows keys
Product: Red Hat Enterprise Linux 8 Reporter: Anthony Zone <azone>
Component: opensshAssignee: Dmitry Belyavskiy <dbelyavs>
Status: CLOSED ERRATA QA Contact: Marek Havrila <mhavrila>
Severity: unspecified Docs Contact:
Priority: low    
Version: 8.2CC: asosedki, dbelyavs, mhavrila
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openssh-8.0p1-7.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:32:04 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:
Attachments:
Description Flags
ssh key created on Windows that can reproduce the issue.
none
Proper id_rsa.pub created in Windows and shows ^M end line none

Description Anthony Zone 2020-11-25 13:49:46 UTC
Created attachment 1733338 [details]
ssh key created on Windows that can reproduce the issue.

Description of problem:

When running a ssh-keygen -l, to verify a public key, on a Windows key, the ^M mangles the output, example:

    $ ssh-keygen -l -f id_rsa.pub 
     (RSA)HA256:reMmmWWV6S1V0ZO6QklXFfm6yPX/QF+v5borcW0DAao ozone@DESKTOP-M2VO07A

vs if I remove the ^M:

    $ ssh-keygen -l -f id_rsa.test.pub 
    2048 SHA256:reMmmWWV6S1V0ZO6QklXFfm6yPX/QF+v5borcW0DAao ozone@DESKTOP-M2VO07A (RSA)

Customer indicates this used to work on RHEL 6, though I haven't attempted.  I did attempt on Fedora 33 and I get the same issue, so it appears that this has not been resolved upstream.

Version-Release number of selected component (if applicable):
openssh-8.0p1-4.el8_1.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. Create ssh key in Windows
2. Copy the key to RHEL 8 
3. Do a 'ssh-keygen -l -f id_rsa.pub' against it 

Actual results:

The (RSA) at the end overwrites the beginning of the output of the key:

     (RSA)HA256:reMmmWWV6S1V0ZO6QklXFfm6yPX/QF+v5borcW0DAao ozone@DESKTOP-M2VO07A


Expected results:

Account for ^M and don't display it properly such as:

    2048 SHA256:reMmmWWV6S1V0ZO6QklXFfm6yPX/QF+v5borcW0DAao ozone@DESKTOP-M2VO07A (RSA)


Additional info:

I understand that this is the ^M character causing issues, but the customer indicates this use dto work in RHEL 6, so this would be a regression.  

Doing a strace we do see that it looks like we're writing this out properly, so maybe this is a shell issue?

    1132759 1605286103.804889 write(1</dev/pts/0<char 136:0>>, "2048 SHA256:reMmmWWV6S1V0ZO6QklXFfm6yPX/QF+v5borcW0DAao ozone@DESKTOP-M2VO07A\r (RSA)\n", 85) = 85 <0.000123>

Comment 1 Jakub Jelen 2020-11-25 17:08:28 UTC
Your strace output shows that the comment fields ends with \r character, which is carriage return without newline, making the rest of the line overwriting the start of the line.

I do not see this byte in the file that I downloaded from the attachment to this bug (maybe it was converted during transfer in bugzilla?):

[jjelen@t490s crypto_policies (master)]$ hexdump -C ~/Downloads/id_rsa.test.pub | tail -2
00000190  37 41 0a                                          |7A.|

Can you run the above command yourself with the key you see this issue with?

The simple workaround is to use dos2unix utility before calling ssh-keygen.

I see last time it might have worked was the RHEL6 since the command did not list the comment at all (correct me if I am wrong, but I see there just a filename).

Reading through the code, there is really no handling of the windows end lines in the code as it prints whatever it reads from file. It looks like this is not handled inside of the getline() eitner, so it will probably require some more checks, but given the priority and simple workaround, I set the priority to low.

Comment 2 Anthony Zone 2020-11-25 17:17:33 UTC
Created attachment 1733419 [details]
Proper id_rsa.pub created in Windows and shows ^M end line

Good day Jakub,

I uploaded the wrong key.  I apologize.  Take 2!

I'll upload the proper one this time, but with a hexdump we definitely see this:

$ hexdump -C id_rsa.pub | tail -n 2
00000190  37 41 0d 0a                                       |7A..|

And yes, the priority is low as we have multiple very easy work arounds to this issue.  Thank you for your help with this.

Comment 3 Anthony Zone 2020-11-25 17:18:57 UTC
As for the comment:

    I see last time it might have worked was the RHEL6 since the command did not list the comment at all (correct me if I am wrong, but I see there just a filename).

That's the theory at this point.  The comment is causing us the grief.

Comment 13 errata-xmlrpc 2021-11-09 19:32:04 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 (Moderate: openssh security 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/RHSA-2021:4368