Skip to content

Instantly share code, notes, and snippets.

@gabrielke
Created November 9, 2017 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielke/e675138ed71510cfce31ab3768fb1ae5 to your computer and use it in GitHub Desktop.
Save gabrielke/e675138ed71510cfce31ab3768fb1ae5 to your computer and use it in GitHub Desktop.
Post CT create script
#!/bin/bash
NUM=$1
if [ x$NUM == x ]; then
echo "ERROR:container id parameter is mandatory"
exit 1
fi;
pct exec $NUM -- apt-get --yes install openssh-server
pct exec $NUM -- apt-get --yes install ansible
pct exec $NUM -- mkdir /root/.ssh
pct push $NUM /etc/lxc_push/authorized_keys /root/.ssh/authorized_keys
pct push $NUM /etc/lxc_push/known_hosts /root/.ssh/known_hosts
pct exec $NUM -- chmod 400 /root/.ssh/authorized_keys
@gabrielke
Copy link
Author

There is one thing missing, the new container's public key has to be added to the ansible host.
Log in or use ssh-keyscan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment