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 |
@ 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. |
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 |
@ 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 Code:
mount -t cifs //server/share /mountpoint -o username=domain_name/myuser Code:
mount -t cifs //server/share /mountpoint -o username=workgroup_name/myuser I hope this helps. |
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 |
@ Reply
Glad to hear that the issue has been resolved!
Could you please mark the thread as solved. |
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.) |
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. |