GCE cloudinit and ubuntu keys from metadata to ubuntu authorized_keys
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Low
|
Shane Peters | ||
cloud-init (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Trusty |
Fix Released
|
Medium
|
Shane Peters |
Bug Description
[Impact]
* Per documentation at https:/
* This works fine in Xenial (16.04) and higher, but doesn't work for Trusty (14.04).
[Test Case]
* Create a file that contains ssh public keys
$ cat googlekeys
test:ssh-rsa <one example key> <email address hidden>
ubuntu:ssh-rsa <a second example key> <email address hidden>
cloudinit:
* Create an ubuntu 14.04 instance
gcloud compute instances create ubuntu1404cloudinit --image-family ubuntu-1404-lts --image-project ubuntu-os-cloud --metadata-
* Create an ubuntu 16.04 instance
gcloud compute instances create ubuntu1604cloudinit --image-family ubuntu-1604-lts --image-project ubuntu-os-cloud --metadata-
* Notice that the ubuntu user in the ubuntu 14.04 instance contains no keys from cloud-init (the keys there are added by the google daemon):
$ sudo cat /home/ubuntu/
# Added by Google
ssh-rsa <the second example key but added by google daemon> <email address hidden>
* However, in 16.04,
$ sudo cat /home/ubuntu/
ssh-rsa <the third example key added by cloud-init> <email address hidden>
ssh-rsa <the second example key added by cloud-init> <email address hidden>
# Added by Google
ssh-rsa <the second example key added by the google daemon> <email address hidden>
[Regression Potential]
* DatasourceGCE.py is heavily modified to fix this behavior in 14.04. That said, there is a medium amount of regression potential when using the GCE datasource. More specificallly, there is now stricter checking of the metadata source when used(platform_
* Significant testing has been completed via the Google Compute platform as well as other none-GCE datasources (lxd) to confirm functionality and to test for possible regressions.
Related branches
- Scott Moser: Approve
-
Diff: 737 lines (+704/-0)4 files modifieddebian/changelog (+9/-0)
debian/control (+1/-0)
debian/patches/lp-1781039-gce-datasource-update.patch (+693/-0)
debian/patches/series (+1/-0)
- Scott Moser: Needs Fixing
-
Diff: 744 lines (+722/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/lp-1781039-gce-datasource-update.patch (+713/-0)
debian/patches/series (+1/-0)
- Scott Moser: Needs Information
-
Diff: 744 lines (+722/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/lp-1781039-gce-datasource-update.patch (+713/-0)
debian/patches/series (+1/-0)
Changed in cloud-init: | |
assignee: | nobody → Shane Peters (shaner) |
Changed in cloud-init: | |
status: | New → Fix Released |
importance: | Undecided → Low |
Changed in cloud-init (Ubuntu): | |
status: | New → Fix Released |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Trusty): | |
status: | New → Confirmed |
importance: | Undecided → Medium |
assignee: | nobody → Shane Peters (shaner) |
tags: | added: sts-sponser |
tags: |
added: sts-sponsor removed: sts-sponser |
tags: |
added: verification-done removed: verification-needed |
tags: | removed: sts-sponsor |
I've tested a "first boot" scenario using a customised image with this patched cloud-init and it works as expected (you can see both cloudinit and ubuntu keys above the 'Added by google' comment).
$ cat googlekeys
carbon:ssh-rsa AAAAB....ZCRI2M shaner@carbon
ubuntu:ssh-rsa AAAAB....65Otq/ shaner@ubuntu
cloudinit:ssh-rsa AAAA..6s3oSv shaner@cloudinit
# USING CUSTOM IMAGE WITH UPGRADED CLOUD-INIT ####### ####### ####### ####### ####### ### from-file= ssh-keys= googlekeys --metadata= block-project- ssh-keys= True _keys
#######
$ gcloud compute instances create trusty1 --image custom-cloud-init --image-project firm-lacing-209716 --metadata-
$ ssh ubuntu@x.x.x.x cat .ssh/authorized
ssh-rsa AAAAB....65Otq/ shaner@ubuntu
ssh-rsa AAAA..6s3oSv shaner@cloudinit
# Added by Google
ssh-rsa AAAAB....65Otq/ shaner@ubuntu
# USING EXISTING IMAGE ####### ####### ####### #### from-file= ssh-keys= googlekeys --metadata= block-project- ssh-keys= True
#######
$ gcloud compute instances create trust2 --image-family ubuntu-1404-lts --image-project ubuntu-os-cloud --metadata-
$ ssh ubuntu@${IP} cat .ssh/authorized _keys
# Added by Google
ssh-rsa AAAAB.....z65Otq/ shaner@ubuntu
$ scp cloud-init_ 0.7.5-0ubuntu1. 23_all. deb ubuntu@${IP}:~/ 0.7.5-0ubuntu1. 23_all. deb cloud/instances _keys
$ ssh ubuntu@${IP} sudo dpkg -i cloud-init_
$ ssh ubuntu@${IP} sudo rm -rf /var/lib/
$ ssh ubuntu@${IP} sudo reboot
$ ssh ubuntu@${IP} cat .ssh/authorized
ssh-rsa AAAA.....6s3oSv shaner@cloudinit
# Added by Google
ssh-rsa AAAAB....65Otq/ shaner@ubuntu
You'll notice in this second example, the 'ubuntu' key from my googlekeys file isn't added on top like you would expect if the image had an upgraded cloud-init. This is because the code is duplicate checking and won't add a key if it already exists.