Created
February 21, 2016 05:45
-
-
Save gpolitis/7ba1b604088511c29297 to your computer and use it in GitHub Desktop.
LXD utils
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/sh -e | |
CONTAINER=$1 | |
lxc exec $CONTAINER -- apt-get -y install openssh-server | |
lxc exec $CONTAINER -- visudo | |
lxc exec $CONTAINER -- mkdir -p /home/ubuntu/.ssh/ | |
lxc file push ~/.ssh/id_rsa $CONTAINER/home/ubuntu/.ssh/id_rsa | |
lxc file push ~/.ssh/id_rsa.pub $CONTAINER/home/ubuntu/.ssh/id_rsa.pub | |
lxc file push ~/.ssh/id_rsa.pub $CONTAINER/home/ubuntu/.ssh/authorized_keys | |
lxc exec $CONTAINER -- chown ubuntu:ubuntu /home/ubuntu/.ssh/ |
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/sh -e | |
# This script expects this input: | |
# | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
#| NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS | | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
#| bitlbee | RUNNING | 192.168.1.58 (eth0) | | NO | 0 | | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
#| firefox | RUNNING | 192.168.1.59 (eth0) | | NO | 0 | | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
#| mail | RUNNING | 192.168.1.56 (eth0) | | NO | 0 | | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
#| znc | RUNNING | 192.168.1.57 (eth0) | | NO | 0 | | |
#+---------+---------+---------------------+------+-----------+-----------+ | |
CONTAINER_NAME=$1 | |
shift | |
CONTAINER_IP=$(lxc list|grep $CONTAINER_NAME|awk '{split($0, a, "|"); print a[4]}'|awk '{split($0,a," "); print a[1]}') | |
exec ssh -X ubuntu@$CONTAINER_IP "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment