Adding Multiple Users to FreeNAS Part 1

1. Figure out what the account names and passwords are going to be. For this example, I’m just going to create a bunch of student accounts, with lame passwords, based on colors, viz…

Student01 – Blue
Student02 – Orange
Student03 – Green
Student04 – Brown
Student05 – Gray
Student06 – Red
Student07 – Black

Etc.

2. Using a terminal program, Log into the FreeNas server using the SSH service. (Make sure SSH has been started on the FreeNas server, via the Services tab.) Using the Mac’s terminal program, you can login with the following command:

ssh 192.168.xx.xx -l root

In Windows, use the free PUTTY program, which has provisions for using SSH to log in.

3. Once you are in, change the directory to your shared student volume.

cd /mnt/StudentData

4. Now you need to use a text editor to create a couple of files. The first file is a list of the user accounts.

nano userlist.txt

Add the account names, one per line.

Student01
Student02
Student03
….

Save this file.

5. Now create a shell batch file which creates all of the student folders.

nano makestfolder.sh

#! /bin/sh

while read username
do
echo $username
mkdir $username
done

Save this file as makestfolder.sh

6. Flag the batch file as executable
chmod 755 makestfolder.sh

7. Now you can run this shell script, using the file of user names for input.

./makestfolder.sh <userlist.txt

This will output a list of names of each user. As long as you don’t see anything weird, the folders will also have been created. You can check by simply doing a directory listing.

ls

This should show all of the folders.

8 Finally, you’ll need to create one more shell script, which we’ll use after we’ve added the user accounts to FreeNas.

nano fixperms.sh

#! /bin/sh
while read username
do
echo $username
chmod 711 /mnt/StudentData/$username
chown $username /mnt/StudentData/$username
done

Save this, and again, change the file permissions on it to allow it to be executable.

chmod 755 fixperms.sh

Obviously, creating these two shell scripts is a one-time thing… we’ll reuse them any time we add new folders.

Now, having created your student folders, you can go back into the FreeNas web interface, and actually create the user accounts. When doing this, you assign the “home directory” for the account to the folder that you’ve just created. (See Part 2)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s