🎉 server code

This commit is contained in:
DrMaxNix 2024-05-07 13:02:33 +02:00
parent 5b09a51bee
commit 442f37a84a
7 changed files with 80 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
authorized_keys
docker-compose.yml

10
Dockerfile Normal file
View File

@ -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

View File

@ -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
```

View File

@ -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:

19
entrypoint.sh Executable file
View File

@ -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

3
motd Normal file
View File

@ -0,0 +1,3 @@
Spiegelei-Server v1.0.0

12
sshd_config Normal file
View File

@ -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