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