Membuat user otomatis dengan Scripting bash shell pada Debian
for i in "$@"; do echo creating user "$i" sudo adduser --gecos "" --disable-password $i echo add user to sudo group sudo usermod -aG sudo $i echo creating ssh folder and authorized_keys sudo -H -u $i bash -c 'mkdir -p /home/"$0"/.ssh' $i sudo -H -u $i bash -c 'chmod 700 /home/"$0"/.ssh/' $i sudo -H -u $i bash -c 'touch 600 /home/"$0"/.ssh/authorized_keys' $i echo buat folder public_html dan mkdir sudo -H -u $i bash -c 'mkdir -p /home/public_html' $i sudo -H -u $i bash -c 'chmod 700 /home/"$0"/public_html' $i sudo -H -u $i bash -c 'mkdir -p /home/"$0"/mail_dir' $i sudo -H -u $i bash -c 'chmod 700 /home/"$0"/mail_dir' $i done
Kemudian simpan dengan nama createuser.sh
Untuk menjalankan silahkan ketik
$/home/samsul/.createuser.sh user1 user2 user3 user4 user5