Easily mount SMB Share on Per User Basis

Clive Menzies clive at clivemenzies.co.uk
Thu Mar 1 14:30:02 UTC 2007


On (01/03/07 03:44), Matthew Flaschen wrote:
> To: Anthony M Simonelli <a.simonelli at sbcglobal.net>,
> Anthony M Simonelli wrote:
> > I have a Ubuntu 6.10 LTSP5 Server running.  I will be adding users to
> > this server that require a connection to a single Windows Share running
> > on a Windows NT Server.  Each need to mount this share, but using each
> > user's credentials so that the correct permissions are applied.
> > Therefore, there will be a mount for each user to the same Windows Share
> > in their HOME directory.  I need it mounted because then the share can
> > be searched and programs that don't use Gnome-vfs can open files, such
> > as Adobe Reader.
> > 
> > My question is, how can I have this share mounted automatically at
> > login?  Would the best solution would be to write a script that uses
> > smbmount and have it run with Gnome's Startup Programs section?
> 
> The below is a hack :) :
> 
> You should just be able to use /etc/fstab
> (http://www.tuxfiles.org/linuxhelp/fstab.html).  For some reason smbfs
> needs root privileges so doing it on login won't work.  Try something like:
> 
> //smb.yourserver.edu/	/home/username/smb	smbfs
> username=username,uid=1000,gid=1000,fmask=700,password=PASSWORD	0	0
> 
> You need to create a separate entry with the username, password,
> mountpoint, uid & gids for each users.  That means all the directories
> will be mounted at the same time (which might be impossible if we're
> talking about a large number of users), but unix permissions should
> prevent users from seeing each others files.
> 
> Also, make sure you run
> 
> sudo chmod go-r /etc/fstab
> 
> to stop users (in theory...) from seeing each others passwords.

Alternatively, set up .smb_pass in each user's home dir
cat .smb_pass
username=<username>
password=<password>

use the cifs module (I usually use modconf but $ sudo modprobe -i cifs
should do it).

and put the following in /etc/fstab (having created the mount point):

//server/sharename /mountpoint	credentials=/home/cma/.smb_pass,uid=<user>,gid=<group>,file_mode=0660,dir_mode=0770 0       0

Regards

Clive

-- 
www.clivemenzies.co.uk ...
...strategies for business






More information about the ubuntu-users mailing list