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
#############################################
$ gcloud compute instances create trusty1 --image custom-cloud-init 
--image-project firm-lacing-209716 --metadata-from-file=ssh-keys=googlekeys 
--metadata=block-project-ssh-keys=True
$ ssh [email protected] cat .ssh/authorized_keys
ssh-rsa AAAAB....65Otq/ shaner@ubuntu
ssh-rsa AAAA..6s3oSv shaner@cloudinit
# Added by Google
ssh-rsa AAAAB....65Otq/ shaner@ubuntu


# USING EXISTING IMAGE
################################
$ gcloud compute instances create trust2 --image-family ubuntu-1404-lts 
--image-project ubuntu-os-cloud --metadata-from-file=ssh-keys=googlekeys 
--metadata=block-project-ssh-keys=True

$ 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}:~/
$ ssh ubuntu@${IP} sudo dpkg -i cloud-init_0.7.5-0ubuntu1.23_all.deb
$ ssh ubuntu@${IP} sudo rm -rf /var/lib/cloud/instances
$ ssh ubuntu@${IP} sudo reboot
$ ssh ubuntu@${IP} cat .ssh/authorized_keys
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.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1781039

Title:
  GCE cloudinit and ubuntu keys from metadata to ubuntu authorized_keys

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1781039/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to