Skip to content

Instantly share code, notes, and snippets.

@dziamid
Forked from w3cj/cj-cloud-init.yml
Last active May 9, 2025 17:33
Show Gist options
  • Save dziamid/0de2761e0ecc4b3e68e2461c60f82930 to your computer and use it in GitHub Desktop.
Save dziamid/0de2761e0ecc4b3e68e2461c60f82930 to your computer and use it in GitHub Desktop.
#cloud-config
users:
- name: dz
ssh_authorized_keys:
- <public-ssh-key>
sudo: ALL=(ALL:ALL) ALL
groups: sudo
shell: /bin/bash
chpasswd:
expire: true
users:
- name: dz
password: changeme
type: text
runcmd:
- sed -i -e '/^\(#\|\)PermitRootLogin/s/^.*$/PermitRootLogin without-password/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)PubkeyAuthentication/s/^.*$/PubkeyAuthentication yes/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
- systemctl restart sshd
- echo "\$nrconf{kernelhints} = -1;" > /etc/needrestart/conf.d/99disable-prompt.conf
- apt update
- apt upgrade -y --allow-downgrades --allow-remove-essential --allow-change-held-packages
- reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment