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 1995840

Summary: [cloudinit] Fix home permissions modified by ssh module
Product: Red Hat Enterprise Linux 8 Reporter: Emanuele Giuseppe Esposito <eesposit>
Component: cloud-initAssignee: Emanuele Giuseppe Esposito <eesposit>
Status: CLOSED ERRATA QA Contact: xiachen
Severity: medium Docs Contact:
Priority: medium    
Version: 8.5CC: eesposit, eterrell, huzhao, jgreguske, lmiksik, ribarry, rlandy, xiachen, xiliang, yacao
Target Milestone: betaKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cloud-init-21.1-7.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1995843 (view as bug list) Environment:
Last Closed: 2021-11-09 18:48:55 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: 1995843    

Description Emanuele Giuseppe Esposito 2021-08-19 21:59:12 UTC
Description of problem:

In upstream PR #956 and BZ 1862967, we updated the file and directory permissions for keys not in
the user's home directory. We also unintentionally modified the
owner within the home directory as well to root, but only when the file/folders specified in AuthorizedKeysFile don't exist. This is okay and still allows ssh login, but not ideal for other ssh components. For example, if cloud-init creates the .ssh folder in /home/user/, the owner of .ssh will be root and ssh-keygen won't allow to create ssh keys in that folder.

LP: #1940233

Version-Release number of selected component (if applicable):
cloud-init-21.1-6.el8

How reproducible:
always

Steps to Reproduce:

1. Use standard AuthorizedKeysFile: 
# cat /etc/ssh/sshd_config | grep AuthorizedKeysFile
AuthorizedKeysFile .ssh/authorized_keys
2. Remove ~/.ssh
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, login is fine
6. run ssh-keygen and save the key in /home/<user>/.ssh

Actual results:
ssh-keygen gives Permission denied on the .ssh folder
This is because the owner of .ssh is root.

Expected results:
ssh-keygen creates the keys, and .ssh is owned by the user

Comment 23 xiachen 2021-09-09 03:47:21 UTC
*** Bug 2000664 has been marked as a duplicate of this bug. ***

Comment 25 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