commit 183561658b4918f2b3634f27629dccffcbff221b Author: Daniel Dolezal Date: Thu Dec 30 01:12:33 2021 +0100 init commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eeea1b5 --- /dev/null +++ b/Dockerfile @@ -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" ] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..4b41c5e --- /dev/null +++ b/entrypoint.sh @@ -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 "$@" diff --git a/motd.txt b/motd.txt new file mode 100644 index 0000000..b32afc5 --- /dev/null +++ b/motd.txt @@ -0,0 +1,5 @@ +Welcome to BorgBackup! + +You can run all borg command here: borg +to Check you Version run: borg -V +