Help please to mount smaba share with write access for a specific user

Running Tumbleweed KDE. I used to use SMB4K for managing mounting and unmounting my Samba shares but now it does not work because of the changes in Samba. So I’ve been trying to use mount.cifs to mount a share and get it to be owned by my user with write access. However everything I’ve tried will only mount it with root access. Also when unmounting it removes the directory used which I also do not want. I’ve tried adding options of user uid and gid but to no avail, the mounted share always ends up as root,root permissions. I do not want to have any of the shares mount at boot time as some of them will not be on the lan as they are on laptops etc which are not powered on all the time. I should point out the share can be accessed using the smb:// protocol in Dolphin but for what I need I have to have it mounted at a specific mount point.

So can someone please point me in the right direction for a command which will mount a share with write access for a specific user and keep the used directory when unmounting the share?

Stuart

You can easily do that from Dolphin - Locations - Network - Add networkconnection. AFAIK

I dont see that option, I do have Add Network Folder but that does not have an option for Samba shares. I’d really like a simple command line command to mount the share as I need it with write access.

Stuart

On demand mounting can be facilitated with an entry in /etc/fstab and the appropriate options ‘noauto’ and ‘x-systemd.automount’ as described in these useful references…

https://wiki.archlinux.org/index.php/fstab#Automount_with_systemd
https://www.freedesktop.org/software/systemd/man/systemd.automount.html
https://www.freedesktop.org/software/systemd/man/systemd.mount.html#

I should point out the share can be accessed using the smb:// protocol in Dolphin but for what I need I have to have it mounted at a specific mount point.

The dolphin ‘smb-kio’ does not mount samba shares as such. It uses libsmbclient to communicate with samba servers to access and manipulate files in an ‘ftp-like’ manner. So, if an application needs direct access to a mounted share it is not an option.

https://www.samba.org/samba/docs/current/man-html/libsmbclient.7.html

So can someone please point me in the right direction for a command which will mount a share with write access for a specific user and keep the used directory when unmounting the share?

Stuart

Can you explain a bit more about the shares you would like to mount? The OS are they hosted may be relevant here, (as that can impact on the samba protocol version and authentication protocols required.)

The shares are a mixture of Windows 7 and Linux, specifically Tumbleweed and Leap on laptops.

Stuart

Something like the following…

//server/share /path_to/mount cifs noauto,x-systemd.automount,x-systemd.device timeout=30,_netdev,guest,uid=client_user,gid=users 0 0

and if authentication required…

//server/share /path_to/mount cifs noauto,x-systemd.automount,x-systemd.device timeout=30,_netdev,username=server_user,password=secret,_netdev,uid=client_user,gid=users 0 0

https://wiki.archlinux.org/index.php/fstab

From swerdna’s samba guide the following information is pertinent regarding Windows shares and Linux samba shares…

Permanent Mounts: Prescribing the owner of the mount on the client So far, these commands haven’t specified an owner for the mount. If the client maps a Windows share-level share, the mount on the client will automagically assume permissions drwxrwxrwx and the ownership will stay with the Linux owner of the directory mount_point. If the client maps a Linux share the mount will automagically assume the permissions on the share on the server and will automagically switch ownership to match the owner on the server (which can be tricky if the owner on the Linux server doesn’t exist on the client).
You can control this by specifying a new owner in the line/mount that you put in fstab. This owner is a Linux user on the client (who might not be a user on the server, that doesn’t matter), e.g. client_user. You can specify the group too, e.g. users. The line in fstab is now like this for a guest-accessible share: