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 - ssh-keygen printing fingerprint issue with Windows keys
Summary: ssh-keygen printing fingerprint issue with Windows keys
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: openssh
Version: 8.2
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: 8.0
Assignee: Dmitry Belyavskiy
QA Contact: Marek Havrila
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-25 13:49 UTC by Anthony Zone
Modified: 2021-11-10 07:10 UTC (History)
3 users (show)

Fixed In Version: openssh-8.0p1-7.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:32:04 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
ssh key created on Windows that can reproduce the issue. (403 bytes, text/plain)
2020-11-25 13:49 UTC, Anthony Zone
no flags Details
Proper id_rsa.pub created in Windows and shows ^M end line (404 bytes, text/plain)
2020-11-25 17:17 UTC, Anthony Zone
no flags Details


Links
System ID Private Priority Status Summary Last Updated
OpenSSH Project 3283 0 None None None 2021-03-19 11:34:33 UTC
Red Hat Product Errata RHSA-2021:4368 0 None None None 2021-11-09 19:32:25 UTC

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


Note You need to log in before you can comment on or make changes to this bug.