1
0

Compare commits

..

3 Commits

Author SHA1 Message Date
9e250080cd feat: support configuring a shell for a user
Some checks failed
continuous-integration/drone/push Build is failing
2022-09-17 14:52:17 +02:00
c8a0086f64 feat: install vim 2022-09-17 14:52:17 +02:00
34ca62efff fix(Dockerfile): fail build when apt-get fails 2022-09-17 14:52:17 +02:00
4 changed files with 17 additions and 10 deletions

View File

@ -1,6 +1,6 @@
FROM debian:bookworm-slim
RUN set -eux; \
RUN set -eux && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \

View File

@ -16,7 +16,7 @@
| --- | --- | --- |
| `ROOT_AUTHORIZED_KEYS` | `/path/to/file` | Path to file that contains the public SSH keys that can be used for root user authentication. This file will be copied to `/root/.ssh/authorized_keys` |
| `HOSTKEYS` | `/path/to/hostkey` | Specifies a (semi-colon separated list of) file(s) containing a private host key used by SSH. |
| `USERADD` | `{username}:{uid}:{gid};...` | Create user account(s) on startup |
| `USERADD` | `{username}:{uid}:{gid}:{shell};...` | Create user account(s) on startup |
| `GROUPADD` | `{groupname}:{gid};...` | Create group account(s) on startup |
| `BASE_DIR` | `/home` | Basedir used for user account creation (Default: `/home`) |
@ -28,7 +28,7 @@ $ docker run -it \
-v $(pwd)/jumpbox:/var/lib/jumpbox \
-e "ROOT_AUTHORIZED_KEYS=/var/lib/jumpbox/authorized_keys"
-e "HOSTKEYS=/var/lib/jumpbox/ssh_host_ed25519_key;/var/lib/jumpbox/ssh_host_rsa_key"
-e "USERADD=jumpbox:1000:1000"
-e "USERADD=jumpbox:1000:1000:/bin/bash"
-e "GROUPADD=jumpbox:1000"
-p 1022:22 \
pommib/jumpbox:latest
@ -50,6 +50,6 @@ services:
environment:
ROOT_AUTHORIZED_KEYS: /var/lib/jumpbox/authorized_keys
HOSTKEYS: /var/lib/jumpbox/ssh_host_ed25519_key;/var/lib/jumpbox/ssh_host_rsa_key
USERADD: jumpbox:1000:1000
USERADD: jumpbox:1000:1000:/bin/bash
GROUPADD: jumpbox:1000
```

View File

@ -1,6 +1,6 @@
#!/bin/sh
set -x
set -ex
IMAGE=pommib/jumpbox:latest
docker pull $IMAGE

View File

@ -22,6 +22,7 @@ if [ ! -d "$BASE_DIR" ]; then
fi
# GROUPADD="group1:1000;group2:1001;group3:1002"
i=""
while [ "$GROUPADD" != "$i" ] ;do
i=${GROUPADD%%;*}
GROUPADD="${GROUPADD#$i;}"
@ -32,20 +33,26 @@ while [ "$GROUPADD" != "$i" ] ;do
groupadd --gid "$GROUP_GID" "$GROUP_NAME"
done
# USERADD="user1:1000:1000;user2:1001:1000;user3:1002:1002"
# USERADD="user1:1000:1000:/bin/bash;user2:1001:1000:/bin/sh;user3:1002:1002:/bin/sh"
i=""
j=""
while [ "$USERADD" != "$i" ] ;do
i=${USERADD%%;*}
USERADD="${USERADD#$i;}"
USER_NAME=${i%%:*}
UID_GID="${i#$USER_NAME:}"
USER_UID="${UID_GID%%:*}"
USER_GID="${UID_GID#$USER_UID:}"
j="${i#$USER_NAME:}"
USER_UID="${j%%:*}"
j="${j#$USER_UID:}"
USER_GID="${j%%:*}"
j="${j#$USER_GID:}"
USER_SHELL=$j
useradd --home-dir "$BASE_DIR/$USER_NAME" --uid "$USER_UID" --gid "$USER_GID" "$USER_NAME"
useradd --home-dir "$BASE_DIR/$USER_NAME" --shell "$USER_SHELL" --uid "$USER_UID" --gid "$USER_GID" "$USER_NAME"
done
# HOSTKEYS="/var/lib/jumpbox/ssh_host_ed25519_key;/var/lib/jumpbox/ssh_host_rsa_key"
i=""
if [ -n "$HOSTKEYS" ]; then
while [ "$HOSTKEYS" != "$i" ]; do
i=${HOSTKEYS%%;*}