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 1310649

Summary: cloud-init does not read instance sskKeys in GCE
Product: Red Hat Enterprise Linux 7 Reporter: Aleksandar Kostadinov <akostadi>
Component: cloud-initAssignee: Lars Kellogg-Stedman <lars>
Status: CLOSED WONTFIX QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: yacao
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-06 19:46:28 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:

Description Aleksandar Kostadinov 2016-02-22 12:28:09 UTC
Description of problem:
Hello, I see that current version of cloud-init shipped with RHEL7.2 latest image from CSB does ignore instance public keys in google compute engine machines' metadata.

On the other hand  see that cloud-init upstream has already updated to support instance level sshKyes:
http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/DataSourceGCE.py

I think it is important to support that as putting all keys in project sshKeys is not always an option. For example creating instances from scripts and jenkins is more secure if the key used is not part of project  keys and be inserted into every launched instance. e.g. script may generate ssh key on the fly and this way making impossible a compromised jenkins instance to result in exposing all GCE machines to potentially disclosed ssh key.

It is not a security issue per se but I'd rate it close to that. It's more find googles idea to insert all project keys in instances weak.

That would allow downloading RHEL7.2 guest image straight from CSP, uploading to GCE and using it without any modifications.

A workaround actually exists. That it to put a command in user-data to append any instance level keys to authorized keys. Here's example user-data:

> #cloud-config
> disable_root: false
> preserve_hostname: true
> runcmd:
> - "curl 'http://metadata.google.internal/computeMetadata/v1/instance/attributes/sshKeys' -H 'Metadata-Flavor: Google' | sed -r -e 's/(^|,)[^\\S]*:/\\1/g' -e 's/,/\\n/g' >> /root/.ssh/authorized_keys"

Comment 2 Lars Kellogg-Stedman 2016-12-06 19:46:28 UTC
We are only able to resolve cloud-init issues that impact functionality in OpenStack.  We will be releasing an updated cloud-init package shortly, based on 0.7.8, that may address this issue if it has been addressed upstream.

Comment 3 Aleksandar Kostadinov 2016-12-06 20:16:14 UTC
I assume that upstream fixed. Code location seems to have changed though:
https://git.launchpad.net/cloud-init/tree/cloudinit/sources/DataSourceGCE.py

I would like to understand though, why we "are only able to resolve cloud-init issues that impact functionality in OpenStack"? If we support running RHEL on GCE why wouldn't we be able to resolve issues?