Shell Script to create multiple users from a list of names in a file.
The script;
- Checks for user's permission to run script.
- Searches for a file named users.csv, where names for users are listed in the current working directory.
- Checks if user group
developers
exists. If not create user group. - Check if users to be created with usernames listed in file already exists. If it does, add user to supplementary group
developers
. - Create new users with username listed in file.
- Creates
.ssh
directory in the home directory of users and assign appropriate user permissions to the directory. - Generates
SSH
connection authorisation keys for each user in the.ssh
directory.
Run script with user that have root privileges like thus:
$ sudo ./adduser.sh
Shell Script to delete multiple users from a list of names in a file.
The script;
- Checks for user's permission to run script.
- Searches for a file named users.csv, where names for users are listed in the current working directory.
- Check if users to be deleted with name listed in file already exists. Skip if it doesn't.
- Delete existing users and their home diectories with usernames listed in file.
Run script with users that have root privileges like thus:
$ sudo ./deluser.sh