2

This is my cloud-init

#cloud-config
package_update: true
package_upgrade: true
users:
  - name: sammy
    ssh-authorized-keys:
      - ssh-rsa abcd
      - ssh-rsa efgh

after i successfully run it on ubuntu 22.04 vps i checked

I see this when i do sudo tail /var/log/cloud-init-output.log

2022-06-07 08:37:38,353 - schema.py[WARNING]: Invalid cloud-config provided:
users.0: {'groups': 'sudo', 'name': 'sammy', 'shell': '/bin/bash', 'ssh-authorized-keys': ['ssh-rsa abcd', 'ssh-rsa defg\n'], 'sudo': ['ALL=(ALL) NOPASSWD:ALL']} is not valid under any of the given schemas

What did I do wrong? and how do I fix the warning? The cloud-init was correctly executed though.

Kim Stacks
  • 585
  • 3
  • 15
  • 33

1 Answers1

6

If you look at the docs, the key name is ssh_authorized_keys rather than ssh-authorized-keys. The latter is deprecated, though it looks like a deprecation warning was missed.

This should work with no warnings:

#cloud-config
package_update: true
package_upgrade: true
users:
  - name: sammy
    ssh_authorized_keys:
      - ssh-rsa abcd
      - ssh-rsa efgh
falcojr
  • 536
  • 1
  • 3
  • 4
  • 1
    Thank you. I copied that from this digitalocean tutorial https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup Which i will tell them ocne they fix their 522 error – Kim Stacks Jun 07 '22 at 16:35
  • I didn't test but i assume you will be right. will test tomorrow as it's way past midnight from where i am – Kim Stacks Jun 07 '22 at 16:36
  • By the way @falcojr would you mind looking at this question? https://superuser.com/questions/1723770/cloud-init-how-to-run-a-curl-before-and-after-every-non-runcmd It's also cloud-init related – Kim Stacks Jun 07 '22 at 16:39
  • I have posted to the digitalocean tutorials. My comment is under moderator review. We see if they will fix it. By the way, thank you for commenting on my other cloud-init question. You're a mensch ‍♂️ – Kim Stacks Jun 09 '22 at 03:59