This file contains hidden or 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
| #!/usr/bin/env bash | |
| # Copying public key (which is located in ~/.ssh/id_rsa.pub) in each LXC container | |
| # (it's required for future Ansible operations) | |
| for CTID in $(pct list | awk 'NR>1 {print $1}'); do | |
| echo "Processing $CTID..." | |
| pct exec $CTID -- mkdir -p /root/.ssh | |
| pct push $CTID ~/.ssh/id_rsa.pub /root/.ssh/temp_key.pub | |
| pct exec $CTID -- sh -c 'cat /root/.ssh/temp_key.pub >> /root/.ssh/authorized_keys && rm /root/.ssh/temp_key.pub' | |
| pct exec $CTID -- chmod 700 /root/.ssh |