Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.