Fix/exit on unlocked user (#9)
* fix unlocking user if user is unlocked * thanks to @alxdembo
This commit is contained in:
parent
9edbfe2df5
commit
c346abfc31
@ -3,7 +3,7 @@ FROM alpine:"${ALPINE_VERSION}"
|
|||||||
|
|
||||||
LABEL maintainer="https://github.com/hermsi1337"
|
LABEL maintainer="https://github.com/hermsi1337"
|
||||||
|
|
||||||
ARG OPENSSH_VERSION="${OPENSSH_VERSION:-8.0_p1-r0}"
|
ARG OPENSSH_VERSION="${OPENSSH_VERSION:-8.1_p1-r0}"
|
||||||
ENV CONF_VOLUME="/conf.d"
|
ENV CONF_VOLUME="/conf.d"
|
||||||
ENV OPENSSH_VERSION="${OPENSSH_VERSION}" \
|
ENV OPENSSH_VERSION="${OPENSSH_VERSION}" \
|
||||||
CACHED_SSH_DIRECTORY="${CONF_VOLUME}/ssh" \
|
CACHED_SSH_DIRECTORY="${CONF_VOLUME}/ssh" \
|
||||||
|
@ -134,11 +134,16 @@ if [[ -n "${SSH_USERS}" ]]; then
|
|||||||
else
|
else
|
||||||
addgroup -g "${USER_GID}" "${USER_GROUP}"
|
addgroup -g "${USER_GID}" "${USER_GROUP}"
|
||||||
fi
|
fi
|
||||||
getent passwd "${USER_NAME}" &>/dev/null || adduser -s "${USER_LOGIN_SHELL}" -D -u "${USER_UID}" -G "${USER_GROUP}" "${USER_NAME}"
|
|
||||||
passwd -u "${USER_NAME}" &>/dev/null
|
|
||||||
mkdir -p "/home/${USER_NAME}/.ssh"
|
|
||||||
|
|
||||||
log " user '${USER_NAME}' created - UID: '${USER_UID}' GID: '${USER_GID}' GNAME: '${USER_GROUP}'"
|
if getent passwd "${USER_NAME}" &>/dev/null ; then
|
||||||
|
log "warning" " desired USER_NAME is already present in system. Skipping creation - USER_NAME: '${USER_NAME}'"
|
||||||
|
else
|
||||||
|
adduser -s "${USER_LOGIN_SHELL}" -D -u "${USER_UID}" -G "${USER_GROUP}" "${USER_NAME}"
|
||||||
|
log " user '${USER_NAME}' created - UID: '${USER_UID}' GID: '${USER_GID}' GNAME: '${USER_GROUP}'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
passwd -u "${USER_NAME}" &>/dev/null || true
|
||||||
|
mkdir -p "/home/${USER_NAME}/.ssh"
|
||||||
|
|
||||||
MOUNTED_AUTHORIZED_KEYS="${AUTHORIZED_KEYS_VOLUME}/${USER_NAME}"
|
MOUNTED_AUTHORIZED_KEYS="${AUTHORIZED_KEYS_VOLUME}/${USER_NAME}"
|
||||||
LOCAL_AUTHORIZED_KEYS="/home/${USER_NAME}/.ssh/authorized_keys"
|
LOCAL_AUTHORIZED_KEYS="/home/${USER_NAME}/.ssh/authorized_keys"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user