Created
November 9, 2017 00:32
-
-
Save gabrielke/e675138ed71510cfce31ab3768fb1ae5 to your computer and use it in GitHub Desktop.
Post CT create script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.