Init: SSH docker for hosting

This commit is contained in:
Luca 2022-02-26 19:27:02 +01:00
commit ecab42144a
5 changed files with 55 additions and 0 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM registry.sindominio.net/debian
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
COPY sshd_config /etc/ssh/sshd_config
ADD entrypoint.sh /
ADD start.sh /
VOLUME /home/user/httpdocs
EXPOSE 22
ENTRYPOINT [ "/bin/sh", "/entrypoint.sh" ]
CMD ["/bin/sh", "/start.sh"]

12
docker-compose.yml Normal file
View File

@ -0,0 +1,12 @@
version: "3"
services:
ssh:
build: .
environment:
SSH_USER: user
SSH_PASS: pass
ports:
- "0.0.0.0:2133:22"
volumes:
- ./data:/home/user/httpdocs
restart: always

11
entrypoint.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e;
echo $SSH_USER:$SSH_PASS
if [ -z `getent passwd $SSH_USER` ]; then useradd $SSH_USER -d /home/user; fi
echo "$SSH_USER:$SSH_PASS" | chpasswd
#echo "/bin/false" | tee -a /etc/shells
usermod $SSH_USER -s /bin/false
exec $@

10
sshd_config Normal file
View File

@ -0,0 +1,10 @@
Port 22
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding no
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp internal-sftp
ForceCommand internal-sftp
ChrootDirectory %h
AllowTcpForwarding no

5
start.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
touch /var/log/ssh
/usr/sbin/sshd -E /var/log/ssh
tail -f /var/log/ssh