7

Is it possible to add ssh authorized keys for multiple users using a #cloud-config file with CloudInit?

I'm trying to initialize a new EC2 instance created from an Amazon Linux AMI using CloudInit. I'm able to add custom ssh authorized public keys to the ec2-user account using something like this:

#cloud-config

ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAA...

What I'd really like to do is create several new users an add a separate public key for each of them. Is it possible to do this using a standard cloud-config directive, or do I just need to write a custom shell script to do that?

2 Answers 2

2

CloudInit doesn't support specifying multiple users to install SSH keys for. You'll need to write your own script to accomplish this.

2
  • 1
    That's what I figured, but the documentation on CloudInit is so spotty I figured there was a chance someone else knew of a feature I didn't. Thanks for the confirmation.
    – Mike Deck
    Feb 4, 2013 at 19:01
  • @MikeDeck It is, I had to look at the source.
    – mgorven
    Feb 4, 2013 at 19:12
7

Looks like you can do this now

#cloud-config
users:
  - default
  - name: jdoe
    gecos: John Doe
    ssh-authorized-keys:
      - ssh-rsa ...
  - name: jroe
    gecos: Jane Roe
    ssh-authorized-keys:
      - ssh-rsa ...

from https://cloudonaut.io/avoid-sharing-key-pairs-for-ec2/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .