This commit is contained in:
Adrian Amaglio 2021-02-17 14:25:56 +01:00
parent 0685e81bb0
commit c7cf872d9c
2 changed files with 11 additions and 6 deletions

View File

@ -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 -------------------------------"

View File

@ -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"