diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..046394b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +authorized_keys +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..501970e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:latest +RUN apk --update add openssh && rm -rf /var/cache/apk/* + +COPY motd /etc/motd +COPY sshd_config /etc/ssh/sshd_config +COPY authorized_keys /etc/ssh/authorized_keys +COPY entrypoint.sh /entrypoint.sh + +EXPOSE 22 +ENTRYPOINT /entrypoint.sh diff --git a/README.md b/README.md index 12ab33a..86e4f55 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # Spiegelei Provide sftp storage to Spiegelei-client + +## Setup Instructions +Clone git repository: +```console +$ git clone https://git.tjdev.de/DrMaxNix/spiegelei-server.git +$ cd spiegelei-server +``` + +Set up local config files: +```console +$ touch authorized_keys +$ nano authorized_keys +``` +```console +$ cp docker-compose.template.yml docker-compose.yml +$ nano docker-compose.yml +``` + +Build and run container: +```console +$ docker compose up -d +``` diff --git a/docker-compose.template.yml b/docker-compose.template.yml new file mode 100644 index 0000000..f9d5eaf --- /dev/null +++ b/docker-compose.template.yml @@ -0,0 +1,12 @@ +services: + main: + restart: unless-stopped + build: + context: . + ports: + - "3322:22" + volumes: + - host_keys:/host_keys + - /mnt/yourdrive:/data +volumes: + host_keys: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..587eb3c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +## HOST KEYS ## +mkdir -p /host_keys +chmod 700 /host_keys + +# check whethre they exist +if [[ ! -f /host_keys/ssh_host_rsa_key || ! -f /host_keys/ssh_host_ecdsa_key || ! -f /host_keys/ssh_host_ed25519_key || ! -f /host_keys/ssh_host_rsa_key.pub || ! -f /host_keys/ssh_host_ecdsa_key.pub || ! -f /host_keys/ssh_host_ed25519_key.pub ]]; then + # create new keys + mkdir -p /host_keys/etc/ssh + ssh-keygen -A -f /host_keys + mv /host_keys/etc/ssh/* /host_keys/ + rmdir /host_keys/etc/ssh +fi + + +## RUN SSH SERVER ## +/usr/sbin/sshd -D -f /etc/ssh/sshd_config diff --git a/motd b/motd new file mode 100644 index 0000000..a06b6bc --- /dev/null +++ b/motd @@ -0,0 +1,3 @@ + + Spiegelei-Server v1.0.0 + diff --git a/sshd_config b/sshd_config new file mode 100644 index 0000000..c61ba21 --- /dev/null +++ b/sshd_config @@ -0,0 +1,12 @@ +Port 22 +HostKey /host_keys/ssh_host_rsa_key +HostKey /host_keys/ssh_host_ecdsa_key +HostKey /host_keys/ssh_host_ed25519_key + +AuthorizedKeysFile /etc/ssh/authorized_keys + +AllowTcpForwarding no +GatewayPorts no +X11Forwarding no + +Subsystem sftp internal-sftp