Fix none root login (#554)

* Fix account locking issue

* Fix script
This commit is contained in:
Pascal Vizeli
2019-03-16 16:00:06 +01:00
committed by GitHub
parent dd44cc922a
commit 67f4e355d3
5 changed files with 29 additions and 5 deletions

View File

@@ -7,10 +7,6 @@ KEYS_PATH=/data/host_keys
AUTHORIZED_KEYS=$(jq --raw-output ".authorized_keys[]" $CONFIG_PATH)
PASSWORD=$(jq --raw-output ".password" $CONFIG_PATH)
# Init defaults config
sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
sed -i s/#LogLevel.*/LogLevel\ DEBUG/ /etc/ssh/sshd_config
if [ -n "$AUTHORIZED_KEYS" ]; then
echo "[INFO] Setup authorized_keys"
@@ -21,6 +17,10 @@ if [ -n "$AUTHORIZED_KEYS" ]; then
chmod 600 ~/.ssh/authorized_keys
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ no/ /etc/ssh/sshd_config
# Unlook account
PASSWORD="$(strings /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c32)"
echo "root:$PASSWORD" | chpasswd 2&> /dev/null
elif [ -n "$PASSWORD" ]; then
echo "[INFO] Setup password login"