Skip to content

Instantly share code, notes, and snippets.

@tomfanning
tomfanning / userdata.sh
Last active April 24, 2024 21:00
AWS EC2 userdata script to set root pw, allow pw logon, auto updates, and set selinux permissive.
#!/bin/bash -e
rootpw="mypassword"
cat /etc/ssh/sshd_config | sed "s/PasswordAuthentication no/PasswordAuthentication yes/" | sed "s/#PermitRootLogin yes/PermitRootLogin yes/" > /etc/ssh/sshd_config
echo "
MaxAuthTries 10" >> /etc/ssh/sshd_config
systemctl restart sshd
echo root:$rootpw | chpasswd