diff --git a/home/scripts/lxc/lab-create.sh b/home/scripts/lxc/lab-create.sh index 403462f..9ef3309 100644 --- a/home/scripts/lxc/lab-create.sh +++ b/home/scripts/lxc/lab-create.sh @@ -17,6 +17,7 @@ sleep 5 # set root password, install SSH, inject key lxc-attach -n "$CONTAINER" -- /bin/bash -c " + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin apt-get update && apt-get install -y openssh-server mkdir -p /root/.ssh chmod 700 /root/.ssh @@ -26,8 +27,11 @@ lxc-attach -n "$CONTAINER" -- /bin/bash -c " " # push the key in -cat "$KEYFILE" | lxc-attach -n "$CONTAINER" -- tee /root/.ssh/authorized_keys > /dev/null -lxc-attach -n "$CONTAINER" -- chmod 600 /root/.ssh/authorized_keys +cat "$KEYFILE" | lxc-attach -n "$CONTAINER" -- /bin/bash -c " + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + tee /root/.ssh/authorized_keys > /dev/null + chmod 600 /root/.ssh/authorized_keys +" # auto-start on boot echo "lxc.start.auto = 1" >> "/var/lib/lxc/${CONTAINER}/config" diff --git a/home/scripts/lxc/lxc-login.sh b/home/scripts/lxc/lxc-login.sh index 02a0910..b5797a3 100644 --- a/home/scripts/lxc/lxc-login.sh +++ b/home/scripts/lxc/lxc-login.sh @@ -11,7 +11,7 @@ fi lxc-start -n "$CONTAINER" 2>/dev/null || true if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then - exec lxc-attach -n "$CONTAINER" -- /bin/bash -c "$SSH_ORIGINAL_COMMAND" + exec lxc-attach -n "$CONTAINER" -- /bin/bash -c "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; $SSH_ORIGINAL_COMMAND" else exec lxc-attach -n "$CONTAINER" -- /bin/login -f root fi