Skip to content

Instantly share code, notes, and snippets.

@m0r13
Created October 25, 2015 11:04
Show Gist options
  • Save m0r13/f1b05db64cfaaa53c002 to your computer and use it in GitHub Desktop.
Save m0r13/f1b05db64cfaaa53c002 to your computer and use it in GitHub Desktop.
#!/bin/bash
key=$(cat $2)
ssh -t $1 "sudo useradd -d /var/lib/ansible -m -u 999 ansible; \
echo 'ansible ALL=NOPASSWD: ALL' | sudo tee /etc/sudoers.d/ansible; \
sudo mkdir /var/lib/ansible/.ssh; \
echo '$key' | sudo tee /var/lib/ansible/.ssh/authorized_keys; \
sudo chown -R ansible:ansible /var/lib/ansible/.ssh;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment