init commit
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
FROM alpine:latest
|
||||
|
||||
ENV USER=borg
|
||||
ENV UID=1000
|
||||
ENV GID=1000
|
||||
|
||||
# Add Folders and Shell Scripts
|
||||
VOLUME ["/.ssh"]
|
||||
VOLUME ["/backup"]
|
||||
COPY motd.txt /etc/motd
|
||||
COPY entrypoint.sh /
|
||||
|
||||
# Install packages
|
||||
RUN apk update ; apk upgrade
|
||||
RUN apk add --no-cache sudo bash tzdata openssh-server openrc \
|
||||
borgbackup
|
||||
|
||||
# Setup SSH-Server
|
||||
RUN sed -ie 's/#Port 22/Port 22/g' /etc/ssh/sshd_config
|
||||
RUN sed -ie 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||
RUN sed -ie 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
||||
|
||||
EXPOSE 22
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Make authorized_keys file
|
||||
touch "/.ssh/authorized_keys"
|
||||
|
||||
# Add User
|
||||
sh -c "echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
|
||||
addgroup -g "$GID" "$USER"
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--home "/" \
|
||||
--ingroup "$USER" \
|
||||
--uid "$UID" \
|
||||
"$USER"
|
||||
echo "$USER:*" | chpasswd
|
||||
|
||||
# Add SSH Keys to authorized_keys
|
||||
for key in /sshkeys/*.pub; do
|
||||
echo "Adding SSH-Key $key"
|
||||
cat "$key" >> "/.ssh/authorized_keys"
|
||||
done
|
||||
echo "" >> "/.ssh/authorized_keys"
|
||||
|
||||
# Change Ownership of SSH-Keys
|
||||
chown -R "$USER":"$USER" "/.ssh"
|
||||
chmod 700 "/.ssh"
|
||||
chmod 600 "/.ssh/authorized_keys"
|
||||
|
||||
# Generate SSH-Keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@"
|
||||
Reference in New Issue
Block a user