Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Can't create shared folder in Nautilus

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
pwzhangzz
Posts: 431
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 27 times

Can't create shared folder in Nautilus

#1 Post by pwzhangzz »

System: Debian 11, fully updated, samba server, smbclient, etc. all installed.

Can't create shared folder from Nautilus. Error message:

"net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share"

Any suggestions?

Marie SWE
Posts: 241
Joined: 2021-04-06 22:14
Location: Sweden / Linköping
Has thanked: 7 times
Been thanked: 9 times

Re: Can't create shared folder in Nautilus

#2 Post by Marie SWE »

Hi :)
I have discovered that you need to run Nautilus/Caja/Nemo as root to get permission to share folders in Debian
Why make things complicated in life, if you can make it easier for yourself... Do it. ;o)
You only have one life, so make the most of it and enjoy it while you can.


steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1418
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 189 times

Re: Can't create shared folder in Nautilus

#4 Post by steve_v »

Marie SWE wrote:Hi :)
I have discovered that you need to run Nautilus/Caja/Nemo as root to get permission to share folders in Debian
No, no you do not. Running GUI applications as root unnecessarily is extremely bad advice, and it's almost always unnecessary. If you need to grant permissions on a resource to some user(s) you use groups, that's what they're for...
Or you use PAM/polkit/whatever newfangled overcomplicated *kit garbage you desire, but I digress :P
pwzhangzz wrote:Any suggestions?
I don't know how much (if any) of this is already set up by default on Debian since I don't run it on my desktop these days (so you may encounter "already exists" type errors below), but the general procedure to get the new(ish) usershares thing working is:

Add:

Code: Select all

usershare allow guests = true
usershare max shares =  5
usershare owner only = true
usershare path = /var/lib/samba/usershares
to /etc/samba/smb.conf (season to taste), and restart samba however you restart stuff with systemd(isaster).

Create a group to which users allowed to create shares will belong, IIRC the usual name is "sambashare".

Code: Select all

# groupadd sambashare
Create the aforementioned (/var/lib/samba/usershares) directory, owned by the above group and with the sticky bit set (i.e. permission bits 1770).

Code: Select all

# mkdir -p /var/lib/samba/usershares
# chown root.sambashare /var/lib/samba/usershares
# chmod 1770 /var/lib/samba/usershares
Add your unprivileged user to the group and logout/login.

Code: Select all

# gpasswd -a [username] sambashare
Note that as samba stores users in a separate and incompatible (windows-style) database, to create shares that require authentication you will likely need to use smbpasswd to add an entry for your user as well. Usage is in the manual.

Considering many file managers moved to usershares a while back, it's a shame there's no Debian wiki page explaining exactly how to do this...

Ed. If you must have pictures (and run KDE), this looks to be pretty well correct. And apparently directories, groups and permissions are already set up in Debian, so you just need the smb.conf edits and to add your user to the group. :)
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

pwzhangzz
Posts: 431
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 27 times

Re: Can't create shared folder in Nautilus

#5 Post by pwzhangzz »

Looks like the new smb.conf works! No need to run Nautilus as root. Will try to run it again in a different installation to make sure it actually works.

pwzhangzz
Posts: 431
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 27 times

Re: Can't create shared folder in Nautilus

#6 Post by pwzhangzz »

steve_v wrote:
Marie SWE wrote:Hi :)
pwzhangzz wrote:Any suggestions?
I don't know how much (if any) of this is already set up by default on Debian since I don't run it on my desktop these days (so you may encounter "already exists" type errors below), but the general procedure to get the new(ish) usershares thing working is:

Add:

Code: Select all

usershare allow guests = true
usershare max shares =  5
usershare owner only = true
usershare path = /var/lib/samba/usershares
to /etc/samba/smb.conf (season to taste), and restart samba however you restart stuff with systemd(isaster).

Create a group to which users allowed to create shares will belong, IIRC the usual name is "sambashare".

Code: Select all

# groupadd sambashare
Create the aforementioned (/var/lib/samba/usershares) directory, owned by the above group and with the sticky bit set (i.e. permission bits 1770).

Code: Select all

# mkdir -p /var/lib/samba/usershares
# chown root.sambashare /var/lib/samba/usershares
# chmod 1770 /var/lib/samba/usershares
Add your unprivileged user to the group and logout/login.

Code: Select all

# gpasswd -a [username] sambashare
Note that as samba stores users in a separate and incompatible (windows-style) database, to create shares that require authentication you will likely need to use smbpasswd to add an entry for your user as well. Usage is in the manual.

Considering many file managers moved to usershares a while back, it's a shame there's no Debian wiki page explaining exactly how to do this...

Ed. If you must have pictures (and run KDE), this looks to be pretty well correct. And apparently directories, groups and permissions are already set up in Debian, so you just need the smb.conf edits and to add your user to the group. :)
Thanks! Will change back to the default/original smb.conf and try your suggestions.

Post Reply