~tardypad/alpine-system

dae82f5c6324ee1ae8cc4365ecc0966bf2ebcec8 — Damien Tardy-Panis 4 months ago 1b40bad
utilities: share SSH agent between host and container
1 files changed, 15 insertions(+), 0 deletions(-)

M utilities/setup-container
M utilities/setup-container => utilities/setup-container +15 -0
@@ 44,4 44,19 @@ lxc config device add "${CONTAINER_NAME}" builds disk \
  path="/home/damien/${REPO_NAME}"
lxc config set "${CONTAINER_NAME}" raw.idmap='both 1000 1000'

# share SSH agent
lxc config device add "${CONTAINER_NAME}" ssh-agent proxy \
  "connect=unix:$( echo "${SSH_AUTH_SOCK}" | cut -f2 -d= )" \
  listen=unix:/home/damien/.ssh-agent.sock \
  bind=container \
  uid=1000 \
  gid=1000 \
  mode=0600 \
  security.uid=1000 \
  security.gid=1000
cat << EOF | lxc exec "${CONTAINER_NAME}" -- /bin/sh
  echo 'export SSH_AUTH_SOCK=/home/damien/.ssh-agent.sock' > /home/damien/.profile
  chown damien:damien /home/damien/.profile
EOF

lxc restart "${CONTAINER_NAME}"