From 1fd5e83338802096d966ff07ab92a95910cb9534 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 12 Feb 2021 23:58:42 +0100 Subject: [PATCH] first working prototype --- Dockerfile | 17 ++++++++++++----- docker-compose.yml | 1 + entrypoint.sh | 10 ++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 9170a82..84a4644 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,24 @@ ENV USERNAME=steam VOLUME [ "/home/${USERNAME}" ] RUN pacman -Syu --noconfirm && \ - pacman -S --noconfirm --needed base-devel openssh git sudo cargo tmux vim wget python unzip bc jq netcat && \ + pacman -S --noconfirm --needed base-devel openssh git sudo cargo tmux screen vim wget python unzip bc jq netcat && \ groupadd -g ${GROUP_ID} ${USERNAME} && \ useradd -u ${USER_ID} -g ${GROUP_ID} -M -d /home/${USERNAME} -s /bin/bash ${USERNAME} && \ chown ${USER_ID}:${GROUP_ID} /home/${USERNAME} && \ echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ - systemctl enable sshd.service && \ - cd /tmp && ls -la && sudo -u ${USERNAME} git clone https://aur.archlinux.org/paru.git && cd paru && \ + cd /tmp && sudo -u ${USERNAME} git clone https://aur.archlinux.org/paru.git && cd paru && \ sudo -u ${USERNAME} makepkg -si --noconfirm && \ - sudo -u ${USERNAME} paru -S --noconfirm steamcmd bsdmainutils + sudo -u ${USERNAME} paru -S --noconfirm steamcmd bsdmainutils && \ + echo "HostKey /home/${USERNAME}/.ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config && \ + echo "HostKey /home/${USERNAME}/.ssh/ssh_host_ecdsa_key" >> /etc/ssh/sshd_config && \ + echo "HostKey /home/${USERNAME}/.ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config && \ + echo "PasswordAuthentication no" >> /etc/ssh/sshd_config && \ + echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \ + echo "PidFile /home/${USERNAME}/.ssh/sshd.pid" >> /etc/ssh/sshd_config USER ${USERNAME} WORKDIR /home/${USERNAME} -CMD top -b +COPY entrypoint.sh /opt/ + +CMD /opt/entrypoint.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 603e105..482b72f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: image: steam-container:latest build: . container_name: steam + hostname: steam-container volumes: - ./steam:/home/steam ports: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..9c0f721 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -r ~/.ssh/ssh_host_rsa_key ]; then + /usr/bin/sshd -D -e +else + ssh-keygen -q -N "" -t rsa -b 4096 -f ~/.ssh/ssh_host_rsa_key + ssh-keygen -q -N "" -t ecdsa -f ~/.ssh/ssh_host_ecdsa_key + ssh-keygen -q -N "" -t ed25519 -f ~/.ssh/ssh_host_ed25519_key + /usr/bin/sshd -D -e +fi \ No newline at end of file