lxc patch 2
This commit is contained in:
@@ -17,6 +17,7 @@ sleep 5
|
|||||||
|
|
||||||
# set root password, install SSH, inject key
|
# set root password, install SSH, inject key
|
||||||
lxc-attach -n "$CONTAINER" -- /bin/bash -c "
|
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
|
apt-get update && apt-get install -y openssh-server
|
||||||
mkdir -p /root/.ssh
|
mkdir -p /root/.ssh
|
||||||
chmod 700 /root/.ssh
|
chmod 700 /root/.ssh
|
||||||
@@ -26,8 +27,11 @@ lxc-attach -n "$CONTAINER" -- /bin/bash -c "
|
|||||||
"
|
"
|
||||||
|
|
||||||
# push the key in
|
# push the key in
|
||||||
cat "$KEYFILE" | lxc-attach -n "$CONTAINER" -- tee /root/.ssh/authorized_keys > /dev/null
|
cat "$KEYFILE" | lxc-attach -n "$CONTAINER" -- /bin/bash -c "
|
||||||
lxc-attach -n "$CONTAINER" -- chmod 600 /root/.ssh/authorized_keys
|
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
|
# auto-start on boot
|
||||||
echo "lxc.start.auto = 1" >> "/var/lib/lxc/${CONTAINER}/config"
|
echo "lxc.start.auto = 1" >> "/var/lib/lxc/${CONTAINER}/config"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ fi
|
|||||||
lxc-start -n "$CONTAINER" 2>/dev/null || true
|
lxc-start -n "$CONTAINER" 2>/dev/null || true
|
||||||
|
|
||||||
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
|
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
|
else
|
||||||
exec lxc-attach -n "$CONTAINER" -- /bin/login -f root
|
exec lxc-attach -n "$CONTAINER" -- /bin/login -f root
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user