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.
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.
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