Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am in charge of a small nfs network and I would like to set the machines to perform different mounts depending on which user logs in. Is this possible?

For example, if user A logs in I want them to see /home/users only and if user B logs in I want them to see /home/users and /home/penguins.

I know I could do this using group permissions but for added security I would be interested if /home/penguins can simply not be mounted at all of user A logs in.

share|improve this question
add comment

2 Answers

Look into using automount from autofs http://www.autofs.org/

A simple way to set this up on Ubuntu is like so:

apt-get install nfs-common autofs

add /home /etc/auto.home to /etc/auto.master
add * nfsserver:/share/& to /etc/auto.home

share|improve this answer
    
How can you use automount to mount on a per user basis? –  felipa Jan 23 '13 at 11:12
    
I have updated my answer. –  Tuim Jan 23 '13 at 11:30
    
Sorry to be dim but how do you specify the per user part? I want user A to be prevented from mounting /home/penguins. –  felipa Jan 23 '13 at 13:20
    
autofs does this automatically for you. You could also add joe fileserver.example.com:/export/home/joe for a user named Joe but using the wildcard and & allows for easy integration of new users. –  Tuim Jan 23 '13 at 13:22
    
Oh maybe I didn't explain something properly. All the users can log in to all the machines (using YP). I want the mount to be different depending on who logs in. –  felipa Jan 23 '13 at 15:54
show 5 more comments

You don't need automount. Just set up the relevant lines in fstab, allowing the mounts in question to be mounted by users (the user option in fstab). Then, edit each user's ~/.profile to add the mount command there. That way, each time the user logs in, the correct drive will be mounted.

If you want to use automount, you can set it up so that the mounts are mounted in each user's home directory. Then, when the user logs in and accesses her $HOME, autofs will mount the drives, or partitions or whatever it is you are mounting.

share|improve this answer
    
How can you read ~/.profile when /home/username is not mounted... Also what if "small nfs network" means 30 to 100 users? –  Tuim Jan 23 '13 at 11:25
    
The question said home/users. If home/username is not mounted, the user can't log in anyway. Perhaps, as you suggest, autofs will fix that and mount ~/ on demand but I have not tried that. As for setting it up for 100 users, that is trivial, that's what scripting is for. –  terdon Jan 23 '13 at 11:32
    
@terdon Would this actually prevent user A from mounting /home/penguins? This is what I would like the result to be. –  felipa Jan 23 '13 at 13:21
    
@felipa, no it wouldn't. It would just cause penguins to not be mounted automatically. Sorry. –  terdon Jan 23 '13 at 13:38
    
No problem. Thanks in any case. –  felipa Jan 23 '13 at 13:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.