diff --git a/test-python-ssh/config/init.sh b/test-python-ssh/config/init.sh index 51d8400..584e966 100755 --- a/test-python-ssh/config/init.sh +++ b/test-python-ssh/config/init.sh @@ -1,5 +1,13 @@ #!/bin/bash -echo INIIIIT +echo " ------------------------------ init.sh file ------------------------------" + +# Allow SSH as root +if [ -z "$(grep '^PermitRootLogin yes' /etc/ssh/sshd_config)" ] ; then + echo "PermitRootLogin yes" >> /etc/ssh/sshd_config +fi # set root passwd echo -e "root\nroot" | passwd + + +echo " ------------------------------ init.sh end -------------------------------" diff --git a/test-python-ssh/entrypoint.sh b/test-python-ssh/entrypoint.sh index 06043c2..8c7ba2c 100755 --- a/test-python-ssh/entrypoint.sh +++ b/test-python-ssh/entrypoint.sh @@ -29,6 +29,7 @@ genPassowrd () { } if [ ! -f $PASSWD_LIST ] ; then for user in $(cat "$USERS_LIST") ; do + if [ -z "$user" ] ; then continue ; fi echo "$user$separator$(genPassowrd 10)" >> $PASSWD_LIST done fi @@ -37,18 +38,14 @@ fi for line in $(cat $PASSWD_LIST) ; do name="$(echo "$line" | cut -d "$separator" -f 1)" pass="$(echo "$line" | cut -d "$separator" -f 2)" + if [ -z "$name" ] || [ -z "$pass" ] ; then echo "Malformed line skipped: '$line'" ; continue ; fi home="$HOME_BASE/$name" mkdir -p "$home" - #useradd --home-dir "$home" --no-user-group -G eleve --shell /bin/bash --root "$home" "$name" useradd --home-dir "$home" --no-user-group -G eleve --shell /bin/bash "$name" echo "$pass\n$pass" | passwd "$name" &> /dev/null chown "$name":eleve "$home" done -# Allow SSH as root -if [ -z "$(grep '^PermitRootLogin yes' /etc/ssh/sshd_config)" ] ; then - echo "PermitRootLogin yes" >> /etc/ssh/sshd_config -fi echo "\nFin de la préparation des utilisateurs.\n"