From 7312c8fe0722618c434c2815d4fb178d517e4373 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 26 Jul 2023 20:56:43 +1000 Subject: [PATCH] Initial release --- Dockerfile | 27 +++++++++++++++++++++++++++ init | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Dockerfile create mode 100755 init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0388b79 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# NAME leenooks/ssh +# VERSION latest + +FROM alpine + +# Change to http respositories, so they we can cache the install packages +RUN if [ -n ${HTTP_PROXY} ] ; then sed -i -e s'/https/http/' /etc/apk/repositories; fi + +ENV SSH_KEY_PATH=/etc/ssh/keys + +# Base +RUN apk add --no-cache bash git unzip openssh +RUN sed -i -e "s:#HostKey\ /etc/ssh:HostKey ${SSH_KEY_PATH}:" /etc/ssh/sshd_config + +RUN adduser -g "Hosting Admin User" -u 1000 -G www-data -h /var/www/html -HD lamp + +# DB Clients +RUN apk add --no-cache mariadb-client postgresql-client + +COPY init /sbin/ + + +VOLUME [ "/etc/ssh/keys" ] +EXPOSE 22 + +# Starting +ENTRYPOINT [ "/sbin/init" ] diff --git a/init b/init new file mode 100755 index 0000000..d52f1d7 --- /dev/null +++ b/init @@ -0,0 +1,32 @@ +#!/bin/sh + +#set -e + +generate_host_key_type() { + local bit_size key_type + + key_type=$1 + if [ ! -f /etc/ssh/ssh_host_"${key_type}"_key ]; then + case $key_type in + ecdsa) bit_size="$ecdsa_bit_size";; + rsa) bit_size="$rsa_bit_size";; + esac + ssh-keygen \ + -q \ + -f ${SSH_KEY_PATH}/ssh_host_"$key_type"_key \ + -N '' \ + -t "$key_type" \ + ${bit_size:+ -b ${bit_size}} || return 1 + fi +} + + +for type in ${key_types_to_generate:-dsa ecdsa ed25519 rsa}; do + generate_host_key_type "$type" || return 1 +done + +/usr/sbin/sshd -e + +# Sleep,enabling our SIGTERM to shut us down gracefully +(while true; do sleep 3600; done) & +wait