LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mounting Samba share in fstab (https://www.linuxquestions.org/questions/linux-newbie-8/mounting-samba-share-in-fstab-903891/)

deity_me 09-19-2011 04:01 PM

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

T3RM1NVT0R 09-19-2011 05:16 PM

@ 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.

deity_me 09-19-2011 10:02 PM

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

T3RM1NVT0R 09-20-2011 02:07 PM

@ 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.

deity_me 09-21-2011 04:19 PM

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

T3RM1NVT0R 09-21-2011 04:56 PM

@ Reply
 
Glad to hear that the issue has been resolved!

Could you please mark the thread as solved.

PTrenholme 09-21-2011 07:25 PM

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.)

durus123 11-23-2011 12:57 PM

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


All times are GMT -5. The time now is 06:09 PM.