LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-19-2011, 05:01 PM   #1
deity_me
LQ Newbie
 
Registered: Sep 2003
Posts: 28

Rep: Reputation: 0
Mounting Samba share in fstab


I've been reading some guides how to mount a samba share from an fstab and I have a question.

I want to add it to the fstab
but I want it to prompt me for a username/password
can this be done?

The guides I've read all put the user/pass in the fstab or in a credentials file.
I want it to ask me for the user/pass when I try to mount it myself.

Thanks
 
Old 09-19-2011, 06:16 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

Hi there,

As far as I am aware it is not possible without mentioning username and password in /etc/fstab or without using credential file. The reason being during startup it reads the /etc/fstab file and mount the partitions on the basis of it.

The processess cannot be halted to put in the password. The best you can do is to create a script which contains the command to mount samba share (just mention the username there not the password) and call that script via /etc/rc.local.

I hope this helps.
 
Old 09-19-2011, 11:02 PM   #3
deity_me
LQ Newbie
 
Registered: Sep 2003
Posts: 28

Original Poster
Rep: Reputation: 0
One more minor question
How do you mount the share as read/write?
This is the command I'm using to mount

mount -t cifs //server/share /mountpoint -o rw,username=myuser

I know I setup the server properly because I can mount it from my Mac and create folders.
When I mount it on my Linux, I get permission denied.

Thanks
 
Old 09-20-2011, 03:07 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

You can mount the share as read/write if in the backend you have specified that share is writable. This is something you need to do in Samba backend. If you have shared a directory via Samba as read only then you cannot write to it.

For the "Permission denied" error the syntax is a bit different. The one you mentioned is:

Code:
mount -t cifs //server/share /mountpoint -o rw,username=myuser
As I mentioned before if share access control is defined in backend. No need to mount it using -o rw. The correct syntax is:

Code:
mount -t cifs //server/share /mountpoint -o username=domain_name/myuser
or

Code:
mount -t cifs //server/share /mountpoint -o username=workgroup_name/myuser
When you are mounting the share you should specify the domain name or the workgroup name as described above.

I hope this helps.
 
Old 09-21-2011, 05:19 PM   #5
deity_me
LQ Newbie
 
Registered: Sep 2003
Posts: 28

Original Poster
Rep: Reputation: 0
Hey

Thanks for the help

I was actually able to get it as read/write by adding

guid=500,uid=500

I dont know what this is but it worked.

Thanks
 
Old 09-21-2011, 05:56 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

Glad to hear that the issue has been resolved!

Could you please mark the thread as solved.
 
Old 09-21-2011, 08:25 PM   #7
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,154

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Just a brief comment: Adding the mount to rc.local would, I believe, not be an effective way to get a "Password?" prompt, since rc.local is run, as "root," by the init script. I just use a .smb_credentials file in my $HOME directory. Since that's a hidden file, and I deny read to group and others, only I (or "root") can access the file.

I suspect that you may be resisting using a credentials file is because you suspect that it may compromise your security, but if nobody but you (and "root") can read the file, I don't think that there's much compromised. Even if someone reads the name in fstab, they will still not be able to read the file. (You'd use something like chmod go-rwx .smb_credentials command to set the file permissions so only you could access that file. See man chmod for details.)
 
Old 11-23-2011, 01:57 PM   #8
durus123
LQ Newbie
 
Registered: Dec 2006
Posts: 6

Rep: Reputation: 0
It is possible to mount the Samba share in the fstab. I did this on a RHEL 4 box and Samba 3.0.

I created a file with the username and password, and protected it with permissions 600. I also made it a dot file, /root/.sambapass just for a bit more obscurity. So my .sambapass looked like:

username = test
password = test123

Then my entry in the fstab file looked like:

//grape/testshare /mountpointname smbfs credentials=/root/.sambapass,uid=apache,gid=apache
grape - Windows box
testshare - Windows share name
mountpointname - where you want the share mounted

The uid and gid are valid on the Linux box. They don't have to be related to any domain account name.

Hope this helps.


Cathy Smith
durus123@yahoo.com
 
  


Reply

Tags
credentials, fstab, samba


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
Mounting Windows share using fstab but the mount folder doesn't populate automaticall chrislski Linux - Networking 4 04-22-2010 10:17 AM
Correct syntax for mounting a windows share in the /etc/fstab file kaplan71 Linux - Software 3 08-17-2009 05:48 PM
Mounting Samba share with fstab icarus127 Linux - Server 8 10-03-2008 01:07 AM
Problem mounting samba share with fstab MBrinkley Linux - Software 3 01-21-2007 10:00 PM
mounting an smbfs share using mount vs /etc/fstab sichen Linux - Networking 4 08-13-2004 07:40 PM


All times are GMT -5. The time now is 11:43 PM.

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