CNT4603 - 2019 Fall
Assignment 8
Program Due Wednesday, November 13 by 11:59pm

Assignment: Scripting

  1. You have received a new batch of distinguished users; their basic information is located in newusers.txt. This file contains a colon-separated entry for each user: the username, the uid, the GECOS information, and the user's preferred shell.
  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. Most (but not all) of these users have provided a public key (or, more informally, "pubkey"), and these pubkeys are at stored at "https://www.cs.fsu.edu/~langley/NEWKEYS/".
  4. The filename pattern for these pubkeys is "USERNAME.pub". For instance, you can use "wget http://www.cs.fsu.edu/~langley/NEWKEYS/jones.pub" to retrieve the pubkey for user "jones".
  5. The Bash script should expect two arguments, the name of the users file file ("newusers.txt", in this case) and the URL where public keys for these users can be found (in this instance, "https://www.cs.fsu.edu/~langley/NEWKEYS/").
  6. 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.
  7. 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 at the URL. (This is slightly tricky, and you must pay close attention to file and directory permissions.)
  8. 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. (This means that if you don't already have sshd installed on your machine, you should add it; the package name is "openssh-server").
  9. Also 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
do
   [ .... ]
done < $userfile
although of course there are many ways to do this, such as using "mapfile" to create an array to iterate over.



No journal is due for this assignment. Please submit your script on Canvas by 11:59pm on Wednesday, November 13.