Author Topic: [Tutorial] Easy usersharing with Samba (like (Ubuntu)  (Read 14805 times)

0 Members and 1 Guest are viewing this topic.

Offline r_a_trip

  • Neuling
  • *
  • Posts: 29
  • Linux geek
  • Branch: Unstable
  • Desktop: Gnome 3.14
  • GPU Card: Intel Mobile 4 Series Integrated Graphics Controller
  • GPU driver: Free
  • Kernel: Linux319-x64
  • Skill: Intermediate
[Tutorial] Easy usersharing with Samba (like (Ubuntu)
« on: 30. September 2014, 15:33:15 »
Admin EDIT: Xfce users see here.


The following tutorial will guide you through setting up usersharing with Samba so that you can use your file manager to share folders (nautilus-share, nemo-share, Thunar Shares Plugin, etc.). Ubuntu style.

I pieced the following together from the Arch wiki about usershares, Ask Ubuntu questions and various other bits on the net.

First we need to install a few packages. Open a terminal and become root (or use sudo).

Install samba, nautilus-share* and gvfs-smb.

   *(or another sharing package for your file manager)

In the terminal, enter:

Code: [Select]
pacman -S samba nautilus-share gvfs-smb
Now we are ready to set up Manjaro for usershares. Usershares allows a non-root user to add, modify, and delete their own samba shares.

First we're going to create the usershare path. This is were samba stores the share configuration (so it's not going in /etc/samba/smb.conf!)

In the terminal, enter:

Code: [Select]
mkdir -p /var/lib/samba/usershare
We have now added the usershares directory in /var/lib/samba.

Next we need to create the sambashare group.

In the terminal, enter:

Code: [Select]
groupadd sambashare
We need to make user root owner of both the usershares directory and the sambashare group.

In the terminal, enter:

Code: [Select]
chown root:sambashare /var/lib/samba/usershare
Because /var/lib/samba/usershare is now owned by root, we need to make the usershare directory accessible for non-root users.

In the terminal, enter:

Code: [Select]
chmod 1770 /var/lib/samba/usershare
This chmod command sets the sticky bit (makes the permissions fixed for non-root users), as signified by the preceding 1 in the 1770 string. The 7+7 signifies that users and groups can read, write and execute. The 0 means that "others" have no rights to the directory.

Now we need to create a new smb.conf from the template conf file.

In the terminal, enter:

Code: [Select]
cp /etc/samba/smb.conf.default /etc/samba/smb.conf
Open the newly created smb.conf in a text editor.

In the terminal, enter:

Code: [Select]
nano /etc/samba/smb.conf
To make usershares possible we need to add the following parameters under section [global].

Code: [Select]
  usershare path = /var/lib/samba/usershare
  usershare max shares = 100
  usershare allow guests = yes
  usershare owner only = yes

Approximately halfway in the [global] section is the parameter "security = user". Find this line and add the following immediately after.

 
Code: [Select]
map to guest = bad user
This line makes it possible for users without a "proper username" to still connect to a share.

Save the smb.conf file with CTRL+O and close nano with CTRL+X.

Now add your user to the sambashare group. Replace <username> with your real username.

In the terminal, enter:

Code: [Select]
usermod -a -G sambashare <username>
We still need to enable the samba service.

In the terminal, enter:

Code: [Select]
systemctl enable smbd nmbd
Code: [Select]
systemctl start smbd nmbd
Log out and log back in. It should now be possible to configure samba shares using the GUI. For instance, in Gnome Files you can right click on any directory and share it on the network.

To be able to share directories in your home (/home/<username>) you also need to add new permissions to your home (/home/<username>). Replace <username> with your own username.

In the terminal, enter:

Code: [Select]
chmod 701 /home/<username>
The 701 gives read, write and execute permissions to the user, zero rights to groups and execute rights to "other". The execute rights for "other" seems to be required for samba to be able to access the lower directories under /home/<username>. Other users can't enter your home directory with only the execute bit set, but it might lessen security, as others now do have permission to execute stuff under your home. There needs to be executable stuff in there beforehand, though, and others need to know the path to the executable by heart, before they can run it. It doesn't seem to have much room for misschief, but caveat emptor.
« Last Edit: 09. January 2015, 02:59:16 by Rob »
# touch universe
# chmod +x universe
# ./universe

Offline mandog

  • Held Mitglied
  • *****
  • Posts: 1921
  • Architect Forum And G+ Forum Owner With Daniel S
  • Branch: All
  • Desktop: Gnome, Mate, E19, Openbox,FLuxbox,Budgie, XFCE openRC,
  • GPU Card: nvidia
  • GPU driver: Non Free
  • Kernel: latest
  • Skill: Advanced
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #1 on: 30. September 2014, 17:09:43 »
I think you need to add this to the wiki as it will help others.
A ENGLISHMAN IN PERU
I'm dyslexic Please do not complain about punctuation or spelling,
FANBOY,Taken from the urban dictionary
 A pathetic insult often used by fanboys themselves to try and put down people who don't like whatever it is they like.

Offline tourada

  • Vollwertiges Mitglied
  • ***
  • Posts: 154
  • ManjaroPek Team
  • Branch: Testing
  • Desktop: ManjaroPek
  • GPU Card: nVidia GTX 750 Ti
  • GPU driver: Free
  • Kernel: Linux-3.14-x86_64
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #2 on: 30. September 2014, 17:13:30 »
+1
This is a nice tutorial. Thanks.

Offline excalibur1234

  • Global Moderator
  • *****
  • Posts: 2508
  • Branch: unstable
  • Desktop: net-minimal + LXQt
  • GPU driver: video-nouveau
  • Kernel: 4.6
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #3 on: 30. September 2014, 20:57:49 »
after asking r_a_trip, i have put a copy of this tutorial on the wiki: https://wiki.manjaro.org/index.php?title=Using_Samba_in_your_File_Manager
Need more information? Search here:   Manjaro Forum   |   Manjaro Wiki   |   Arch Wiki

Offline mandog

  • Held Mitglied
  • *****
  • Posts: 1921
  • Architect Forum And G+ Forum Owner With Daniel S
  • Branch: All
  • Desktop: Gnome, Mate, E19, Openbox,FLuxbox,Budgie, XFCE openRC,
  • GPU Card: nvidia
  • GPU driver: Non Free
  • Kernel: latest
  • Skill: Advanced
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #4 on: 30. September 2014, 22:46:13 »
A ENGLISHMAN IN PERU
I'm dyslexic Please do not complain about punctuation or spelling,
FANBOY,Taken from the urban dictionary
 A pathetic insult often used by fanboys themselves to try and put down people who don't like whatever it is they like.

Offline Toppy

  • Neuling
  • *
  • Posts: 14
  • Branch: Testing
  • Desktop: Cinnamon 2.4.6
  • GPU Card: GTX 770
  • GPU driver: non-free
  • Kernel: 3.18.5-1 x64
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #5 on: 23. November 2014, 21:44:00 »
Thank you !

Worked perfectly !

 :-*

Offline rydhwan

  • Sr. Mitglied
  • ****
  • Posts: 287
  • slowly
  • Branch: unstable
  • Desktop: Plasma 5, Gnome, Cinnamon, Deepin, Unity,
  • GPU Card: Intel
  • GPU driver: free driver
  • Kernel: linux 4.1
  • Skill: Novice
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #6 on: 05. December 2014, 10:01:20 »
what's about share printer bethwin linux and win$ ?
American dream. welcome to Guantánamo civil-isation

we are all different ... this is our common

Offline r_a_trip

  • Neuling
  • *
  • Posts: 29
  • Linux geek
  • Branch: Unstable
  • Desktop: Gnome 3.14
  • GPU Card: Intel Mobile 4 Series Integrated Graphics Controller
  • GPU driver: Free
  • Kernel: Linux319-x64
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #7 on: 05. December 2014, 13:03:47 »
what's about share printer bethwin linux and win$ ?

I haven't had the need to do printer sharing, but the Arch wiki has this entry:
https://wiki.archlinux.org/index.php/CUPS_printer_sharing

This should work equally well for Manjaro.
# touch universe
# chmod +x universe
# ./universe

Offline rydhwan

  • Sr. Mitglied
  • ****
  • Posts: 287
  • slowly
  • Branch: unstable
  • Desktop: Plasma 5, Gnome, Cinnamon, Deepin, Unity,
  • GPU Card: Intel
  • GPU driver: free driver
  • Kernel: linux 4.1
  • Skill: Novice
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #8 on: 05. December 2014, 16:58:19 »
I haven't had the need to do printer sharing, but the Arch wiki has this entry:
https://wiki.archlinux.org/index.php/CUPS_printer_sharing

This should work equally well for Manjaro.

yes nice but very hard comprehension
if any simple method with examples
laptop with win$ print ok to desktop with linux thanks
American dream. welcome to Guantánamo civil-isation

we are all different ... this is our common

Offline taxistacuatroplazas

  • Neuling
  • *
  • Posts: 14
  • Taxista colabora con la ley
  • Branch: stable
  • Desktop: Xfce
  • GPU Card: desktop->nVidia GTS250; laptop->intel HD4000+nvidia620M
  • GPU driver: non free
  • Kernel: linux3.16-x64
  • Skill: Novice
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #9 on: 07. December 2014, 10:19:44 »
thanks for the tuto

 just one question, since manjaro upgraded to 8.11 some things have changed. I'm using the Xfce 8.11 edition, and I still don't know whats best for my interests, samba shares or ssh access for rsync (or both). Mostly, I need to sync files&folders between PCs and phones with different operating systems: manjaro, windows 8, debian, android, iOS... being my NAS a bsd based system (NAS4free). The NAS already has a samba & a ssh service running, but I sometimes need to sync or/and access files stored in my main desktop PC (manjaro) from my laptop, phone etc...

 I would like to keep my manjaro installs as simple as possible, and with only true needed modifications and AUR packages.
 
 Has anybody tried this in manjaro xfce 8.11?
 
« Last Edit: 07. December 2014, 10:50:46 by taxistacuatroplazas »

Offline newvista

  • Neuling
  • *
  • Posts: 4
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #10 on: 09. January 2015, 02:41:34 »
I was looking forward to finally having found a solution to sharing files on my local network but alas, it was not to be. After following these instructions to the letter I am not allowed access to my shared folder from any of my three other Linux boxes. Here are my notes on my experience.

1. pacman -S samba nautilus-share gvfs-smb This command was not necessary. Samba, thunar-share, and gvfs-smb are already installed on 0.8.11
2. After following the rest of the instructions to the letter I saw that the default domain is WORKGROUP so I changed the smb.conf entry to match, after a couple of failed logins.
3. After editing smb.conf I ran testparm as advised by nano and got the message: WARNING: Ignoring invalid value 'user map to guest = bad user' for parameter 'security'
4. Here is the rest of the output of testparm:
Processing section "[homes]"
Processing section "[printers]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
   server string = Samba Server
   log file = /var/log/samba/%m.log
   max log size = 50
   printcap name = /etc/printcap
   dns proxy = No
   usershare allow guests = Yes
   usershare max shares = 100
   usershare path = /var/lib/samba/usershare
   idmap config * : backend = tdb
   hosts allow = 192.168.1., 192.168.2., 127.

[homes]
   comment = Home Directories
   read only = No
   browseable = No

[printers]
   comment = All Printers
   path = /var/spool/samba
   printable = Yes
   print ok = Yes
   browseable = No

Any ideas?

Cheers,
Lorne.

Offline Rob

  • Core Team
  • *****
  • Posts: 5390
  • Alias: Korrode
  • Branch: Unstable
  • Desktop: Xfce+Compiz
  • GPU Card: nVidia GTX560Ti
  • GPU driver: non-free
  • Kernel: linux314 x64
  • Skill: Advanced
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #11 on: 09. January 2015, 02:56:56 »
https://forum.manjaro.org/index.php?topic=11810.msg146682#msg146682
Remember if you're trying to share stuff in your home folder, but your home folder's permissions are set so only you have read access, it won't work for unauthenticated guests. You can change this with:
Code: [Select]
chmod 755 /home/username(replace "username" with your actual username)
Understand that this means other system users will get read access to your home folder.

Offline newvista

  • Neuling
  • *
  • Posts: 4
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #12 on: 09. January 2015, 04:37:19 »
https://forum.manjaro.org/index.php?topic=11810.msg146682#msg146682

Nope. Doesn't work. Neither does chmod 777. I'm confused because am I not an authorized user if I am logging in over the network?

Edit: and, it is my intention to get this job done in a SECURE manner one day. I really don't like opening up all my data to the world like this. I will continue to struggle through to learn and understand.

Thanks,
Lorne.
« Last Edit: 09. January 2015, 04:42:45 by newvista »

Offline Rob

  • Core Team
  • *****
  • Posts: 5390
  • Alias: Korrode
  • Branch: Unstable
  • Desktop: Xfce+Compiz
  • GPU Card: nVidia GTX560Ti
  • GPU driver: non-free
  • Kernel: linux314 x64
  • Skill: Advanced
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #13 on: 09. January 2015, 04:48:51 »
Nope. Doesn't work. Neither does chmod 777. I'm confused because am I not an authorized user if I am logging in over the network?

Edit: and, it is my intention to get this job done in a SECURE manner one day. I really don't like opening up all my data to the world like this. I will continue to struggle through to learn and understand.

Thanks,
Lorne.

Did you read the rest of the post i linked to and try as it suggests?

Offline newvista

  • Neuling
  • *
  • Posts: 4
  • Skill: Intermediate
Re: [Tutorial] Easy usersharing with Samba (like (Ubuntu)
« Reply #14 on: 09. January 2015, 05:21:06 »
Did you read the rest of the post i linked to and try as it suggests?

I have now. It's working! Thank you very much.

Lorne.