Skip to content

Instantly share code, notes, and snippets.

@madalinignisca
Last active November 24, 2023 06:41
Show Gist options
  • Save madalinignisca/00ce6d59d4cb3d33a20b4bb60512ddbb to your computer and use it in GitHub Desktop.
Save madalinignisca/00ce6d59d4cb3d33a20b4bb60512ddbb to your computer and use it in GitHub Desktop.
Minimal cloud init suitable for any public cloud server instance

Cloud init snippets

Mostly used by me for Hetzner cloud, but should work with all Public Cloud server providers.

  • cloud-init.yml
    • please ensure to set your user, group for the normal user you want to use
    • ssh_import_id can be used with github usernames instead of ssh_authorized_keys
    • disable_root: true ensures root can't ssh in
    • optionally add a sshd extra config that will secure more; tweak TcpForwarding and PermitTunnel as your requiments are!
#cloud-config
groups:
- usergroup
users:
- name: username
primary_group: usergroup
groups: sudo
shell: /bin/bash
ssh_authorized_keys:
- your_cool_ssh_public_key
sudo: ALL=(ALL) NOPASSWD:ALL
disable_root: true
ssh_pwauth: false
@madalinignisca
Copy link
Author

#cloud-config
system_info:
  default_user:
    name: "hercules"
    primary_group: "hercules"
    groups: "sudo"
    shell: "/bin/bash"
    ssh_authorized_keys:
      - "ssh-ed25519 SET YOUR OWN!!!"
    lock_passwd: true
    sudo: "ALL=(ALL) NOPASSWD:ALL"

users:
  - default

disable_root: true
ssh_pwauth: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment