Fstab mount smbfs share for user noauto asking for password via GUI
Solution 1
You have two options:
-
I believe you are being asked the SAMBA password, so add in the password to the
fstab
entry:username=administrator,password=admin_samba_password,domain=domain,user,rw,noauto
If you do not want the password in
fstab
, use a credentials file as described in this blog entry.Run the following commands as root, but change the path as you see fit:
mkdir -p /path/securedir chmod 0700 /path/securedir chown root /path/securedir
Then create a file
/path/securedir/fileshare
with the following contents:username=yourusername password=yourpass
Now append
credentials=/path/securedir/fileshare
to your fstab entry. Your other option, and the one I use, is
autofs
. It takes a little time to configure, but it is mounted on demand and is invisible to the end user.
Solution 2
bodhi.zazen: I believe you are being asked the SAMBA password
Yes it's the samba password that is being asked for in the terminal. There doesn't seem to be a good solution to bringing a GUI popup to enter the SAMBA password. And since I don't want to save the password in either credential file, fstab or individual autofs files. I will live with it as it is and start a terminal and write:
mount ~/npn/d
and then enter the SAMBA password in the terminal.
Solution 3
Faced with the same problem. For me mounting a CIFS share from a NAS
Problems being faced...
1/ mount has no method of specifying a password handler (such as used by sudo, ssh, etc)
2/ Putting the password in the fstab makes it readable by any one on the system at any time!
3/ mount can be given a password as a option but that means it is on the command line and for a brief moment the password is visible to anyone on the system. But that appears the only way.
4/ mount will only accept options when it is run as root, but if "mount.cifs" is made SUID, then you don't need to run mount as root!
Current Solution.
Given "/usr/libexec/openssh/x11-ssh-askpass" available on most systems (see http://www.ict.griffith.edu.au/anthony/crypto/passwd_input.txt for alternatives). And "/etc/fstab" defines the mount point a "/mnt/cifs".
Then this works as a GUI mount command, but requires 2 passwords... your SUDO (login) password and your CIFS password.
SUDO_ASKPASS=/usr/libexec/openssh/x11-ssh-askpass sudo -A \
mount -o "password=$(/usr/libexec/openssh/x11-ssh-askpass 'CIFS Password')" /mnt/cifs
UPDATE: If you make /sbin/mount.cifs SUID you can do away with the mount and the /etc/fstab (though you may like to keep the fstab to allow you to umount it).
/sbin/mount.cifs -o "user=username,pass=$(/usr/libexec/openssh/x11-ssh-askpass 'CIFS Password')" //machine/share /mnt/cifs
Related videos on Youtube
slingshot
Updated on September 18, 2022Comments
-
slingshot over 1 year
I'm trying to do a connection for my work computers d: from my laptop. Altough to have direct access to the disk I need to use the computers administrator account. And I would not like to save the password for the administrator account in fstab file on my laptop.
# work share //172.16.8.2/d$ /home/user/domain/d smbfs username=administrator,domain=domain,user,rw,noauto 0 0
This is how it looks in the terminal
$ mount ~/npn/d Password:
And I get the thing mounted in no time.
Now to the trouble: If I try to "click" the d "drive" in the file browser I'm met by this error box:
Unable to mount d
Password: mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)Logic, because the graphical interface can't throw me a password login promt like the terminal.
Is there any way for me to solve this problem, to just be able to "click" on the unmounted d drive and get a GUI passpromt thrown?
-
0xC0000022L about 11 yearswouldn't it be better to quote relevant parts from the linked content? Especially with the credential file? The reason the credential files are superior to throwing it into the
fstab
is becausefstab
can usually be read by anyone, whereas the credential file can be protected extra. -
Panther about 11 yearsDepends on what the OP wants, I can flesh out the answer
-
Paŭlo Ebermann over 8 yearsHmm, I would like to get a GUI prompt for the password (and not have it in yet another file). :-/
-
Panther over 8 years@PaŭloEbermann - Ask your own question. Posting in the comments does you little or no good.
-
Paŭlo Ebermann over 8 yearsThat question would be a duplicate to this one (it also asks for a GUI prompt), though ... I guess I'll try, maybe something did change in the last two years.