Skip to content

Instantly share code, notes, and snippets.

@ismailkarsli
Last active August 28, 2023 12:10
Show Gist options
  • Save ismailkarsli/234020c31adc69291f157e356a5eb6a0 to your computer and use it in GitHub Desktop.
Save ismailkarsli/234020c31adc69291f157e356a5eb6a0 to your computer and use it in GitHub Desktop.
cloud-init.yaml
#cloud-config
users:
- name: ismail
groups: users, admin
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPdJr63tCOvAaA42XTABCY1BL6jRNwq7qNF5uoNNsqoY ismail@karsli.net
package_update: true
package_upgrade: true
runcmd:
- sed -i -e '/^\(#\|\)PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 3/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
- sed -i '$a AllowUsers ismail' /etc/ssh/sshd_config
- reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment