Ask Your Question

SSH key gets Injected to wrong user by cloud-init

asked 2019-02-21 07:30:11 -0500

Openstackuser2013 gravatar image

updated 2019-02-21 07:42:19 -0500

I am trying to get ssh key injected to my new user but instead it gets added to other user account on image. My image is based on the Ubuntu cloud image and I have my added my user account to it.

When I launch new vm from that image my user account does not get the key added to its authorized keys. Instead key added to authorized keysof user named ubuntu.

In my cloud-ini config I have:

     name: myuser
     gecos: Ubuntu
     shell: /bin/bash

In cloud-init logs I see the key being written to wrong user: 2019-02-21 12:47:32,888 -[DEBUG]: Writing to /home/ubuntu/.ssh/authorized_keys - wb: [600] 397 bytes

I tried deleting the ubuntu user but it did not help.

How can I configure cloud-init to inject the key to myuser instead of ubuntu.

edit retag flag offensive close merge delete


Can you share more of your cloud.cfg? Do you attach any user-data file to the instance? I also recommend to delete all previous data from any cloud-init processes before uploading it as a new base image.

eblock gravatar imageeblock ( 2019-02-22 04:19:00 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-02-22 04:51:49 -0500

Openstackuser2013 gravatar image

I found the cause and it was error I made into cloud.cgf.

I had accidentally commented out these lines:

   - default

When I removed them from comments the injection worked correctly.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2019-02-21 07:30:11 -0500

Seen: 915 times

Last updated: Feb 22 '19