From 2aa4908aba40b1cf75e33611e12ffc2e8c5cfd79 Mon Sep 17 00:00:00 2001 From: Zak Bearman Date: Thu, 15 Jan 2026 00:07:35 +0000 Subject: [PATCH] Add Create-Ansible-User.sh --- Create-Ansible-User.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Create-Ansible-User.sh diff --git a/Create-Ansible-User.sh b/Create-Ansible-User.sh new file mode 100644 index 0000000..7e20caf --- /dev/null +++ b/Create-Ansible-User.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Exit immediately on error +set -e + +# Create ansible user with /bin/bash shell +sudo useradd -m -s /bin/bash ansible + +# Add ansible user to the sudo group +sudo usermod -aG sudo ansible + +# Grant passwordless sudo access +echo "ansible ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null + +# Create .ssh directory and add public key +sudo mkdir -p /home/ansible/.ssh +echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzq9JFipLZUMOqPIckLgBhnc/QkybYhzJdPr9AElebQuVef+6mjE5kw7pi4Se+XmjBh32HSXAPgZ4QKH88FePtAoHMDXRICVuP7hBSP6Z24VEOthSE9DywPSSokdT1K30SRYqCiS+4cdTCC8qDjACINrPyHO6w+hS6XUnoMU5OHia2Es41u/S5VHYrETj92iPzXwtiLAzLH2z5A1gESi5N9UK2hqojks0p4Z4LUhr5P+a/LPYxZ0jJTK3Vy1gRI8+r/nua2OAHT/pXiWgAnt56o+iMbqjQFGQEEfSgHsprLU7NXWqDLZyP00/JKp27IsZREOnt8jcFzcK1Jby9JOO1 ansible@AMS-ANS01" | sudo tee /home/ansible/.ssh/authorized_keys > /dev/null + +# Set proper permissions and ownership +sudo chown -R ansible:ansible /home/ansible/.ssh +sudo chmod 700 /home/ansible/.ssh +sudo chmod 600 /home/ansible/.ssh/authorized_keys + +echo "Ansible user created and configured successfully."