SSHct: allowed to save user password in /home/.$CTUSER.shadow

File should be owned by root.root and mode should be 640

Otherwise entrypoint.sh will fall back to $CTUSERPWD
This commit is contained in:
Andrey Kartashov 2018-01-23 00:21:06 +07:00
parent 18a63fccd9
commit 937f057686

View file

@ -11,7 +11,12 @@ update-locale LANG=$CTLOCALE
echo "AllowUsers $CTUSER" >> /etc/ssh/sshd_config
useradd --uid $CTUSERID --user-group --shell /bin/bash $CTUSER
if [ -f /home/.$CTUSER.shadow -a \
"$(stat --dereference --printf='%u %g %a' /home/.$CTUSER.shadow)" == "0 0 640" ]; then
echo $CTUSER:"$(cat /home/.$CTUSER.shadow)" | chpasswd -e
else
echo $CTUSER:"$CTUSERPWD" | chpasswd
fi
passwd -u $CTUSER
usermod -a -G sudo $CTUSER