Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/charleszlu/murmur-info.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'entrypoint.sh')
-rw-r--r--entrypoint.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100644
index 0000000..5b92c87
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# generate host keys if not present
+ssh-keygen -A
+
+# set root login mode by password or keypair
+if [ "${KEYPAIR_LOGIN}" = "true" ] && [ -f "${HOME}/.ssh/authorized_keys" ] ; then
+ sed -i "s/#PermitRootLogin.*/PermitRootLogin without-password/" /etc/ssh/sshd_config
+ sed -i "s/#PasswordAuthentication.*/PasswordAuthentication no/" /etc/ssh/sshd_config
+ echo "Enabled root-login by keypair and disabled password-login"
+else
+ sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
+ if [ -n "${ROOT_PASSWORD}" ] && [ "${ROOT_PASSWORD}" != "root" ]; then
+ echo "root:${ROOT_PASSWORD}" | chpasswd
+ fi
+ echo "Enabled root-login by password"
+fi
+
+# do not detach (-D), log to stderr (-e), passthrough other arguments
+exec /usr/sbin/sshd -D -e "$@" \ No newline at end of file