#cloud-config
users:
- name: USERNAME
ssh_authorized_keys:
- "ssh-ed25519 SSH_KEY PUB"
sudo: ALL=(ALL:ALL) ALL
groups: sudo
shell: /bin/bash
chpasswd:
expire: true
users:
- name: USERNAME
password: PASSWORD
type: text
runcmd:
- sed -i '/PermitRootLogin/d' /etc/ssh/sshd_config
- echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
- sed -i '/PubkeyAuthentication/d' /etc/ssh/sshd_config
- echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
- sed -i '/PasswordAuthentication/d' /etc/ssh/sshd_config
- echo "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
Last active
May 31, 2024 08:18
-
-
Save jhahspu/6dd9cb7b98d7b8763e8a0dd62c6973e1 to your computer and use it in GitHub Desktop.
cloudCfg
- generate ssh key
ssh-keygen -t ed25519- name file, save
- Setup server, wait for pass
- SSH into server
useradd -m -U -s /bin/bash -G sudo USERNAMEpasswd PASSWORD
- Install anything that might require root
- Edit
sshd_config
sudo vi /etc/ssh/sshd_configorsudo nano /etc/ssh/sshd_config- change
PermitRootLogin yesto no - add
AllowUsers USER1 USER2 USERetcenable user for SSH MaxAuthTriesset to 2AllowTcpForwardingno - Disables port forwarding.X11Forwardingno - Disables remote GUI view.AllowAgentForwardingno - Disables the forwarding of the SSH login.AuthorizedKeysFile .ssh/authorized_keys- The .ssh/authorized_keys2 file should be removed.- save and exit:
:wqor :q!exit without save
- Apply settings
ssh -tto test for errorssystemctl restart ssh- if no errors restart SSH service
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment