Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

TLDR: I want to configure a box that is running Ubuntu Desktop and has two users so that it automounts a password protected Samba share when one user logs in, and doesn't when the other logs in.

Long version

On my home network, I have two boxes: One runs Ubuntu Desktop, and the other is my file server that contains two password-protected samba shares (no guest access).

Users and accounts: There are two users, Bob and Jane. Bob and Jane both have their own separate usernames and passwords in all three places (i.e. separate Unix accounts on the desktop and file server, and separate samba accounts).

Samba shares: The file server has two samba shares, Secrets and Shared. Secrets is configured so that Bob is the only user who can connect to it (in smb.conf under [Secrets], write list = bob, guest ok = no, etc). My question isn't about how to configure the samba share (sorry this is taking so long to set up my question).

Auto mounting the samba shares: When Bob logs into the Ubuntu Desktop, Secrets is automounted using Bob's own samba creds, Nautilus displays Secrets as one of the places under "Computer" in the left hand nav bar so he can get to it without lifting a finger, the files and folders under that share display as being owned by Bob (ls -l /media/Secrets), and the file permissions display as -rw------- and folder permissions as drwx------. This I've accomplished by adding the following to my /etc/fstab with the separate file that contains Bob's samba creds.

//centaroo.local/Secrets  /media/Secrets  cifs  uid=bob,gid=bob,credentials=/home/bob/.smbcredentials,iocharset=utf8,sec=ntlm,file_mode=0600,dir_mode=0700  0  0

Here's the problem, and here comes my question: When Jane logs in, she, too, sees the label "Secrets" displayed prominently in the left hand nav bar in Nautilus, which is not the end of the world because she still gets access denied when she tries to click on it, but I'd prefer if she didn't even see the Secrets share in Nautilus. In other words, I want to change the settings somehow so that when Jane logs in, she doesn't even know Secrets is there, it doesn't attempt to automount, etc.

How do I do this? Since I want to automount Secrets for one user and not the other, is fstab the wrong way? Is it time for me to look into autofs, or is there a way to do what I want? I've followed instructions for mounting Windows shares permanently and glanced over documentation on autofs, but I'm not clear whether autofs is the answer. If anyone can point me in the right direction, I'd really appreciate it. Also, if there's any extra info that you need in order to help me, please indicate so in the comments. Thanks!

share|improve this question
    
After sleeping on it, I've decided to try a different approach. Since I want the automounting to be user-specific when each user logs in, instead of editing /etc/fstab, I'm going to try setting up mount scripts that run automatically on login using the Startup Applications tool that comes with Ubuntu Desktop. –  Scott Feb 4 at 15:19

1 Answer 1

up vote 0 down vote accepted

I figured out how to do this without touching fstab, as I mentioned in my comment. The way I solved this problem is by adding a script in Startup Applications so that it gets run when my user logs in (but not when a different user logs in), and then I set up the script so that it can be run as root without entering a password. For more details the steps I took and how to run a startup script as root without supplying a password, see "Mount samba share at login using startup script (not fstab)" and "How do I sudo a command in a script without being asked for a password."

share|improve this answer

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.