I want to mount a password-protected SMB share (served by a Windows machine). The share is protected by a user name and password, and I may not write the password in a file, I want to be prompted for the password at mount time.
I need a solution that works even for when the user on the client machine does not have any administrative privileges, so whatever method is used to mount the share must not allow him to get root permissions. The initial installation can be done as root. Users must be able to specify arbitrary server names. My immediate need is with Ubuntu 12.04, but the wider applicable a solution is the better.
The client is headless, so I'm looking for a command-line tool.
What I tried:
mount.cifs
: while it can be made setuid root, its authors do not consider it secure. Running it undersudo
has the same problem.smbnetfs
,fusesmb
: I couldn't convince either of them to prompt me for a password.- Nautilus and gvfs:
gvfs-mount smb://servername/sharename
fails withError mounting location: volume doesn't implement mount
.
How can I mount a Samba share from the command line, as a non-root user, with a password prompt?
Best Answer
“Error mounting location: volume doesn't implement mount” apparently translates to “I need D-Bus but it isn't available”. (Thanks to venturax's guru colleague for this information.) Within an SSH session, I can use
gvfs-mount
provided thatdbus-daemon
is launched first and the environment variableDBUS_SESSION_BUS_ADDRESS
is set.gvfs-mount
and other GVFS utilities must all talk to the same D-Bus session. Hence, if you use multiple SSH sessions or otherwise use mounts across login sessions, you must:See Reuse D-Bus sessions across login sessions for that.