Skip to content

Instantly share code, notes, and snippets.

@svengo
Forked from psct/debansstrap.sh
Last active March 25, 2021 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svengo/91ee29f483c251161ee887dcca18a7a1 to your computer and use it in GitHub Desktop.
Save svengo/91ee29f483c251161ee887dcca18a7a1 to your computer and use it in GitHub Desktop.
Prepare fresh Debian for ansible management by created user "ansible" in sudoers (needs public ssh-Key in PUBKEY)
#!/bin/bash
# enable host for ansible
set -e
PUBKEY=""
id -u ansible > /dev/null 2>&1 || adduser ansible --disabled-password --gecos "" --quiet
mkdir -p /home/ansible/.ssh
echo "$PUBKEY" > /home/ansible/.ssh/authorized_keys
chown -R ansible /home/ansible/.ssh
apt-get update
apt-get install sudo
grep -q ansible /etc/sudoers.d/99-ansible || echo "ansible ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers.d/99-ansible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment