Update bootstrap script
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
PUBKEY=./id_ansible.pub
|
if [ -z $1 ];
|
||||||
|
then
|
||||||
|
echo 'Please, provide the path to the Ansible public key as an argument'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PUBKEY=$1
|
||||||
|
|
||||||
useradd ansible --create-home --shell /bin/bash
|
useradd ansible --create-home --shell /bin/bash
|
||||||
# Ensure existing but unusable password (for Ubuntu)
|
# Ensure existing but unusable password (for Ubuntu)
|
||||||
usermod -p '*' ansible
|
usermod -p '*' ansible
|
||||||
mkdir /home/ansible/.ssh
|
mkdir /home/ansible/.ssh
|
||||||
chown -R ansible:ansible /home/ansible/.ssh
|
|
||||||
install -m 600 $PUBKEY /home/ansible/.ssh/authorized_keys
|
install -m 600 $PUBKEY /home/ansible/.ssh/authorized_keys
|
||||||
|
chown -R ansible:ansible /home/ansible/.ssh
|
||||||
chmod 700 /home/ansible/.ssh
|
chmod 700 /home/ansible/.ssh
|
||||||
# Allow passwordless sudo
|
# Allow passwordless sudo
|
||||||
echo "ansible ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ansible
|
echo "ansible ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ansible
|
||||||
|
|||||||
Reference in New Issue
Block a user