Skip to content

Instantly share code, notes, and snippets.

@mbround18
Last active September 13, 2023 06:48
Show Gist options
  • Save mbround18/66ac1436ecddbc122e70465330bc4d05 to your computer and use it in GitHub Desktop.
Save mbround18/66ac1436ecddbc122e70465330bc4d05 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
ANSIBLE_USER="ansible"
ANSIBLE_PUB_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMGGvMjigF1/Sm30OWfP/Fsh3jYyO26HRd2anCooO68K ansible"
GITHUB_GIST_URL="https://gist.githubusercontent.com/mbround18/f49c06af1fe4c6c420f5b99cbc5deb6f/raw/57b1280bea0a2086a8806b923c611f2577b50563/pub-key"
# Install Deps
apt-get update && apt-get install -y curl wget gosu openssh-server openssh-client sudo
# Initialize ssh
systemctl enable sshd
systemctl start sshd
# Add login creds
curl "${GITHUB_GIST_URL}" > ~/.ssh/authorized_keys
# Create the User
id -u ansible &>/dev/null || adduser --disabled-password ansible
# Setup user
gosu ansible bash -c 'rm -rf ~/.ssh/authorized_keys'
gosu ansible bash -c 'mkdir -p ~/.ssh/'
gosu ansible bash -c "echo '${ANSIBLE_PUB_KEY}' > ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment