CNT4603 - 2015 Summer
Assignment 5
Journals Due Tuesday, October 20 Thursday, October 22, at the beginning of class.

Assignment: Scripting

  1. You have received a new batch of distinguished users; their basic information is located in newusers.tar. Inside of the tar file, there is a file called "newusers.txt" which contains a colon-separated entry for each user: the username, the uid, the GECOS information, and the user's preferred shell. Also in the tar file you will find a public key for each of these users in the subdirectory pubkeys/.
  2. Please write a Bash script to add these users to your Debian machine as local users (you might to verify that no name clashes occur, though, before you proceed!)
  3. The Bash script should expect two arguments, the name of the users file file (newusers.txt, in this case) and the directory where their public keys are stored (pubkeys/, in this case.)
  4. The script should, for each new user, create a home directory on your Debian box with the usual files from /etc/skel, but put the home directories in /home/users/USERNAME/, not just /home/USERNAME.
  5. Please use the user id from the file to create the home directories. Each user should also have his own group, where the group id matches the user id. Don't assign passwords to these accounts; instead, set it up so that the users can login using the public key provided in the tar file.
  6. Please add a test user to the newusers.txt with a public key for whom you also have the corresponding private key and verify that you can ssh into this test user's account, and that all permissions and directories are set up correctly for that user from within that okay.
  7. Create a /scratch/USERNAME/ directory for each user, and make sure that it is owned by the correct user and has the correct group number.

As a suggestion, your internal loop could look something like

while IFS=: read name uid gecos homedir
   [ .... ]
done < $userfile
although of course there are many ways to do this, such as using Bash's mapfile to create an array to iterate over.

A journal is due for this assignment. Make sure that you document in your journal all of the steps that you went through. In particular, please make sure that your script is included.

Please turn in a printed copy of this assignment at the beginning of class on Tuesday, October 20.

Please turn in this assignment on Blackboard before midnight on Thursday, October 22.