initial commit

This commit is contained in:
Pin
2022-12-20 22:15:44 -05:00
commit 9a0c74b701
7 changed files with 104 additions and 0 deletions

11
client/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM alpine:3.16
RUN apk --no-cache add openrc openssh bash && \
ssh-keygen -A && \
mkdir -p /run/openrc && \
touch /run/openrc/softlevel
COPY scripts /opt/scripts
RUN chmod 700 /opt/scripts
ENTRYPOINT ["/opt/scripts/setup.sh"]

25
client/scripts/setup.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
TEAM_NUM=${TEAM_NUM:=10}
for (( i=1; i<=TEAM_NUM; i++ )); do
echo "Creating Team ${i}"
adduser -D "team${i}"
chmod 750 "/home/team${i}"
PASSWORD="TEAM${i}_PASSWORD"
if [[ -z "${!PASSWORD}" ]]; then
PASSWORD=$(head -c10 </dev/urandom | base64)
else
PASSWORD=${!PASSWORD}
fi
echo -e "Password: ${PASSWORD}\n"
echo -e "${PASSWORD}\n${PASSWORD}" | passwd "team${i}"
unset PASSWORD
done
if [[ -n "${SSHD_CHALLENGE_DIR}" ]]; then
sed -i "s|^AuthorizedKeysFile.*|AuthorizedKeysFile ${SSHD_CHALLENGE_DIR}|" /etc/ssh/sshd_config
fi
/usr/sbin/sshd -D