Skip to content

Instantly share code, notes, and snippets.

@tomfanning
Last active April 24, 2024 21:00
Show Gist options
  • Save tomfanning/1eb299915ca061e9a937ae3efc77c1c2 to your computer and use it in GitHub Desktop.
Save tomfanning/1eb299915ca061e9a937ae3efc77c1c2 to your computer and use it in GitHub Desktop.
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
yum install yum-cron nano -y
cat /etc/yum/yum-cron.conf | sed "s/apply_updates = no/apply_updates = yes/" > /etc/yum/yum-cron.conf
systemctl restart yum-cron
echo "SELINUX=permissive
SELINUXTYPE=targeted" > /etc/selinux/config
setenforce permissive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment