entrypoint.sh 490 B

1234567891011121314151617181920212223242526
  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. # TODO remove:
  15. passwd -u "$USER" 2>/dev/null
  16. fi
  17. done
  18. set -x
  19. sed -i "s/^AllowUsers .*/AllowUsers ${USERS//,/ }/" /etc/ssh/sshd_config
  20. exec "$@"