Initial release

This commit is contained in:
Deon George 2023-07-26 20:56:43 +10:00
commit 7312c8fe07
2 changed files with 59 additions and 0 deletions

27
Dockerfile Normal file
View File

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

32
init Executable file
View File

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