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.
Additional Information from test on OpenStack.
This issue happened on OpenStack env once, not always reproduce on OpenStack.
$ rpm -q cloud-init
cloud-init-21.1-8.el9.noarch
RHEL version
Red Hat Enterprise Linux release 9.0 Beta (Plow)
5.14.0-1.el9.x86_64
Same error log as bug description.
From cloud-init.log, we can see there should be two lines about removing ssh_host_rsa_key files but on the instance that went wrong, it does not contain these logs.
- util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_rsa_key
- util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_rsa_key.pub
List files in /etc/ssh, we can see the group owner of ssh_host_rsa_key file is 'ssh_keys', not root.
$ ls -al /etc/ssh
total 608
drwxr-xr-x. 4 root root 4096 Sep 5 22:38 .
drwxr-xr-x. 93 root root 8192 Sep 5 22:38 ..
-rw-r--r--. 1 root root 570321 Aug 10 11:35 moduli
-rw-r--r--. 1 root root 1921 Aug 10 11:35 ssh_config
drwxr-xr-x. 2 root root 28 Sep 1 02:40 ssh_config.d
-rw-------. 1 root root 513 Sep 5 22:38 ssh_host_ecdsa_key
-rw-r--r--. 1 root root 186 Sep 5 22:38 ssh_host_ecdsa_key.pub
-rw-------. 1 root root 419 Sep 5 22:38 ssh_host_ed25519_key
-rw-r--r--. 1 root root 106 Sep 5 22:38 ssh_host_ed25519_key.pub
-rw-r-----. 1 root ssh_keys 2578 Sep 5 22:38 ssh_host_rsa_key
-rw-r--r--. 1 root root 554 Sep 5 22:38 ssh_host_rsa_key.pub
-rw-------. 1 root root 3702 Sep 5 22:38 sshd_config
drwx------. 2 root root 28 Sep 1 02:40 sshd_config.d
So the question is, why did it not attempt to remove ssh_host_rsa_key before generate it?
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 (new packages: cloud-init), 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/RHBA-2022:2308
Created attachment 1821670 [details] os_tests.tests.test_cloud_init.TestCloudInit.test_check_cloudinit_log_traceback.debug Description of problem: Upload rhel-guest-image-9.0-20210906.6.aarch64 to the aws and found below warning in 'cloud-init.log'. 2021-09-08 08:42:18,295 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/i-076adaf0b0fd87d2a/sem/config_ssh - wb: [644] 24 bytes 2021-09-08 08:42:18,296 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-076adaf0b0fd87d2a/sem/config_ssh (recursive=False) 2021-09-08 08:42:18,297 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-076adaf0b0fd87d2a/sem/config_ssh (recursive=False) 2021-09-08 08:42:18,297 - helpers.py[DEBUG]: Running config-ssh using lock (<FileLock using file '/var/lib/cloud/instances/i-076adaf0b0fd87d2a/sem/config_ssh'>) 2021-09-08 08:42:18,298 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ecdsa_key 2021-09-08 08:42:18,298 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ecdsa_key.pub 2021-09-08 08:42:18,298 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ed25519_key 2021-09-08 08:42:18,298 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ed25519_key.pub 2021-09-08 08:42:18,298 - subp.py[DEBUG]: Running command ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', '/etc/ssh/ssh_host_rsa_key'] with allowed return codes [0] (shell=False, capture=True) 2021-09-08 08:42:19,551 - util.py[WARNING]: Failed generating key type rsa to file /etc/ssh/ssh_host_rsa_key 2021-09-08 08:42:19,552 - util.py[DEBUG]: Failed generating key type rsa to file /etc/ssh/ssh_host_rsa_key Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/cloudinit/config/cc_ssh.py", line 241, in handle out, err = subp.subp(cmd, capture=True, env=lang_c) File "/usr/lib/python3.9/site-packages/cloudinit/subp.py", line 293, in subp raise ProcessExecutionError(stdout=out, stderr=err, cloudinit.subp.ProcessExecutionError: Unexpected error while running command. Command: ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', '/etc/ssh/ssh_host_rsa_key'] Exit code: 1 Reason: - Stdout: Generating public/private rsa key pair. /etc/ssh/ssh_host_rsa_key already exists. Overwrite (y/n)? Stderr: 2021-09-08 08:42:19,666 - util.py[DEBUG]: Restoring selinux mode for /etc/ssh (recursive=True) 2021-09-08 08:42:19,679 - subp.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ecdsa', '-N', '', '-f', '/etc/ssh/ssh_host_ecdsa_key'] with allowed return codes [0] (shell=False, capture=True) 2021-09-08 08:42:19,687 - util.py[DEBUG]: Restoring selinux mode for /etc/ssh (recursive=True) 2021-09-08 08:42:19,692 - subp.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ed25519', '-N', '', '-f', '/etc/ssh/ssh_host_ed25519_key'] with allowed return codes [0] (shell=False, capture=True) 2021-09-08 08:42:19,700 - util.py[DEBUG]: Restoring selinux mode for /etc/ssh (recursive=True) 2021-09-08 08:42:19,706 - util.py[DEBUG]: Reading from /etc/ssh/ssh_host_rsa_key.pub (quiet=False) #rpm -q cloud-init cloud-init-21.1-7.el9.noarch RHEL Version: RHEL-9.0(5.14.0-1.el9.aarch64) How reproducible: 100% Steps to Reproduce: 1. start a rhel9 t4g.small 2. check cloud-init.log Actual results: Failed generating key type rsa to file /etc/ssh/ssh_host_rsa_key Expected results: Can generate key type rsa to file /etc/ssh/ssh_host_rsa_key Additional info: - N/A