Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-22-2008, 01:46 PM   #1
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 240

Rep: Reputation: 30
using smbfs to mount windows share

Is there anyway to have a normal user mount there own shares? This is a public machine in the school and they log on as a guest. When they do work, I want them to click on the launcher on the desktop and mount their share from a windows server. I put this into a script:
mount -t smbfs -o username=swu //macx/swu /home/$USER/Desktop/Share
and it works if you have the root password and put sudo in front. Is there any way for them to mount it with their own password?
Old 04-22-2008, 04:52 PM   #2
Registered: Dec 2007
Posts: 59

Rep: Reputation: 16
You can configure sudo on the machine to ask for the user password, and grant root privilege only for this command and no other (better security wise).

You need to edit the file /etc/sudoers, it is done in console with the special editor visudo, just type the visudo command as root.

To force sudo to ask for the user password comment out the lines (not needed on every distro, ie. not on Ubuntu) :

#Defaults targetpw # ask for the password of the target user i.e. root
#ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!

just as they are above. Then grant permission for the sudoing user to use the command you want with :

user_login ALL = (root) PASSWD: /bin/mount -t smbfs -o username=swu //macx/swu /home/$USER/Desktop/Share

"user_login" as to be replaced by the allowed users (user1, user2, user3...), "ALL" means from any location, local or remote, "PASSWD" isn't always necessary as it is the default, "NOPASSWD:" would grant permission without asking for a password,then the command you want to allow with full path to the executable since sudo doesn't change the user's PATH variable (command1, command2...).

Hope it helps, as usual "man sudo" is a good idea for there is differences in "sudo" use between distributions.
Old 04-22-2008, 04:55 PM   #3
Registered: Mar 2005
Location: Cascade Mountains WA USA
Distribution: Linux From Scratch (LFS)
Posts: 149

Rep: Reputation: 16
actually sudo by default wants the user's password, not root's password

the idea is that the user doesn't know root password and that root has seen to the security.
Old 04-22-2008, 04:57 PM   #4
Registered: Apr 2008
Location: Gliwice, Poland
Distribution: Any. BSD most often ;-)
Posts: 31

Rep: Reputation: Disabled
Just put the mount line into /etc/fstab:

//macx/swu /mnt/publicshare smbfs user,rw,noauto,username=swu

note the red "user" option and the green "noauto". First one makes the share mountable by users. The second prevents the system from mounting the share during startup. The drawback is that the directory is mounted in a fixed place (/mnt/publicshare and not user desktop). But why not make a symlink?

There is also a pam module called pam_mount that is used to automatically mount and dismount a specified share for user session. It's highly configurable so you could specify a separate mountpoint for each user. There is a drawback: you have to know what PAM modules are...

Old 04-23-2008, 05:28 AM   #5
Registered: Dec 2007
Posts: 59

Rep: Reputation: 16
Originally Posted by taxtropel View Post
actually sudo by default wants the user's password, not root's password

the idea is that the user doesn't know root password and that root has seen to the security.
Depends on the distro, try Suse...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
NFS mount of smb mount of windows share: permission denied problem :( Bagatur Linux - Networking 4 07-07-2009 11:34 AM
Cannot mount Windows Share!! charles20hk Linux - Networking 3 11-29-2006 03:03 AM
when trying to mount a windows share I'm getting jcombs_31 Slackware 11 01-04-2006 06:48 PM
mount -t smbfs let's dissapear /mnt/MyMount share in Linux hc2469 Linux - General 0 08-30-2004 06:19 AM
mounting an smbfs share using mount vs /etc/fstab sichen Linux - Networking 4 08-13-2004 06:40 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration