From 928c2ffd2b3e058c49c41e884d97f9a5b6303139 Mon Sep 17 00:00:00 2001 From: Boshi Lian Date: Sun, 30 Jul 2017 02:42:29 +0800 Subject: [PATCH] auto generate server key if not exists --- Dockerfile | 5 ++++- entrypoint.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 893826b7..62682175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,12 @@ RUN apt-get update && apt-get install -y libpam0g-dev libpam-google-authenticato RUN ln -sf /usr/include/security/_pam_types.h /usr/include/security/pam_types.h -RUN go get -d -tags pam github.com/tg123/sshpiper/sshpiperd +ADD . /go/src/github.com/tg123/sshpiper/ RUN go install -ldflags "$(/go/src/github.com/tg123/sshpiper/sshpiperd/ldflags.sh)" -tags pam github.com/tg123/sshpiper/sshpiperd EXPOSE 2222 +ADD entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] + CMD ["/go/bin/sshpiperd"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..65641f29 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euo pipefail + + +if [ ! -f /etc/ssh/ssh_host_rsa_key ];then + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +exec "$@"