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 1862967 - [cloud-init]Customize ssh AuthorizedKeysFile causes login failure
Summary: [cloud-init]Customize ssh AuthorizedKeysFile causes login failure
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: cloud-init
Version: 8.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Emanuele Giuseppe Esposito
QA Contact: Huijuan Zhao
URL:
Whiteboard:
: 1905466 (view as bug list)
Depends On:
Blocks: 1905466 1979099
TreeView+ depends on / blocked
 
Reported: 2020-08-03 10:48 UTC by Yuxin Sun
Modified: 2021-11-10 01:28 UTC (History)
12 users (show)

Fixed In Version: cloud-init-21.1-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1905466 1979099 (view as bug list)
Environment:
Last Closed: 2021-11-09 18:48:55 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gitlab redhat/rhel/src cloud-init merge_requests 25 0 None None None 2021-07-13 10:00:43 UTC
Gitlab redhat/rhel/src cloud-init merge_requests 28 0 None None None 2021-08-09 22:01:32 UTC
Red Hat Product Errata RHEA-2021:4294 0 None None None 2021-11-09 18:49:54 UTC

Internal Links: 1919972

Description Yuxin Sun 2020-08-03 10:48:49 UTC
If modify sshd_config to change AuthorizedKeysFile value from '.ssh/authorized_keys' to another file(e.g. .ssh/authorized_keys2) and run cloud-init config_ssh module, cloud-init will write publickeys to .ssh/authorized_keys, which causes login failure.

Version-Release number of selected components (if applicable):
cloud-init-19.4-7.el8

RHEL Version:
RHEL-8.3

How reproducible:
100%

Steps to Reproduce:
1. Prepare a VM with cloud-init enabled
2. Modify /etc/ssh/sshd_config to remove default .ssh/authorized_keys and change to another filee.g.)
# cat /etc/ssh/sshd_config | grep AuthorizedKeysFile
AuthorizedKeysFile .ssh/authorized_keys2
3. Remove /var/lib/cloud/instance/sem/config_ssh
4. systemctl restart cloud-init ; systemctl restart sshd
5. Try to ssh login through the cloud-init created user

Actual results:
Cannot login: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
The public key is written into .ssh/authorized_keys but not .ssh/authorized_keys2

Expected results:
Can login successfully. The public key is written into .ssh/authorized_keys2

Additional info:
It was involved by patch https://github.com/canonical/cloud-init/commit/f1094b1a539044c0193165a41501480de0f8df14 which was for BZ#1642008 .
For ssh, customer can customize the AuthorizedKeysFile. And ssh service will use this file to authenticate. The cloud-init doesn't write public key into the customized file which causes this issue.
In cloud-init function "extract_authorized_keys" in ssh_util.py, it writes public key to ".ssh/authorized_keys" which is hard coded. Suggest to read the file from sshd_config AuthorizedKeysFile.

Comment 1 John Ferlan 2020-08-11 20:02:37 UTC
Assigned to Rick for initial triage per bz process and age of bug created or assigned to virt-maint without triage

Comment 5 Eduardo Otubo 2020-09-24 15:26:49 UTC
Pull request filed at https://github.com/canonical/cloud-init/pull/586

Comment 9 Eduardo Otubo 2020-12-08 12:21:12 UTC
*** Bug 1905466 has been marked as a duplicate of this bug. ***

Comment 14 Huijuan Zhao 2020-12-15 09:11:41 UTC
Tested with cloud-init-20.3-6.el8, the issue is gone.

Comment 22 Huijuan Zhao 2021-01-06 00:52:39 UTC
Move to VERIFIED according to comment 14.

Comment 54 errata-xmlrpc 2021-11-09 18:48:55 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 (cloud-init 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/RHEA-2021:4294


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