entrypoint.sh 467 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. set -e
  3. if [ ! -f "$SSHD_HOST_KEYS_DIR/rsa" ]; then
  4. ssh-keygen -t rsa -b 4096 -N '' -C '' -f "$SSHD_HOST_KEYS_DIR/rsa"
  5. fi
  6. if [ -z "$USERS" ]; then
  7. echo '$USERS is not set'
  8. exit 1
  9. fi
  10. IFS=','
  11. for USER in $USERS; do
  12. if ! id "$USER" 2>/dev/null >/dev/null ; then
  13. (set -x; adduser -D "$USER")
  14. passwd -u "$USER" 2>/dev/null
  15. fi
  16. done
  17. set -x
  18. sed -i "s/^AllowUsers .*/AllowUsers ${USERS//,/ }/" /etc/ssh/sshd_config
  19. exec "$@"