Difference between revisions of "Using Samba in your File Manager"

Revamp page to simplify and match current Manjaro packaging
imported>Cscs
(Format, expand)
imported>Dalto
(Revamp page to simplify and match current Manjaro packaging)
Line 1: Line 1:
{{Warning|<nowiki></nowiki>
__TOC__
(30 June 2018) This page needs updating; search the forums for more current info  }}




The following tutorial will guide you through setting up usersharing with Samba so that you can use your file manager to share folders. Ubuntu style.
=Accessing SMB Shares from the File Manager=


Dolphin is capable of mounting smb file shares without needing any additional packages.  All other file managers require installing the package {{ic|gvfs-smb}}.  This is present by default in most Mnajaro editions but if you need to install it you can so with:
pamac install gvfs-smb


== Installation ==


First we need to install a few packages. The base package {{ic|samba}} is required in addition to a few more depending on your desktop or file manager.
=Sharing Files from the File Manager=


==== GTK+ ====
The following will guide you through setting up user sharing with Samba so that you can use your file manager to share folders.


Install samba, gvfs-smb, and the share package for your file manager.


'''Cinnamon / Nemo'''
== Installation ==
sudo pacman -S samba gvfs-smb nemo-share
 
'''Gnome / Nautilus'''
sudo pacman -S samba gvfs-smb nautilus-share
 
'''Mate / Caja'''
sudo pacman -S samba gvfs-smb caja-share
 
'''XFCE / Thunar'''
sudo pacman -S samba gvfs-smb thunar-shares-plugin
 
==== KDE ====
 
KDE has the ability to browse shares built-in, but still requires {{ic|samba}} to share folders and {{ic|kdenetwork-filesharing}} for settings and easier use.
 
sudo pacman -S samba kdenetwork-filesharing
 
 
== Configuration ==


==== Automatic ====
Depending on which file manager you use there are different packages to install.  Please reference the appropriate section for your file manager.


sudo pacman -S manjaro-settings-samba


==== Manual ====
The {{ic|manjaro-settings-samba}} package will install a basic config and enable the file sharing services.  The whole process is nicely automated.


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 <code>/etc/samba/smb.conf</code>)
===Nemo - Cinnamon===
In the terminal, enter:


  mkdir -p /var/lib/samba/usershare
  pamac install nemo-share manjaro-settings-samba


We have now added the usershares directory in <code>/var/lib/samba</code>.


Next we need to create the sambashare group. In the terminal, enter:
===Nautilus - Gnome/Budgie===


  groupadd sambashare
  pamac install nautilus-share manjaro-settings-samba


We need to make user <code>root</code> owner of both the usershares directory and the sambashare group.


In the terminal, enter:
===Caja - MATE===


  chown root:sambashare /var/lib/samba/usershare
  pamac install caja-share manjaro-settings-samba


Because <code>/var/lib/samba/usershare</code> is now owned by <code>root</code>, we need to make the usershare directory accessible for non-root users.
In the terminal, enter:


chmod 1770 /var/lib/samba/usershare
===Thunar - XFCE===


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.
pamac install thunar-shares-plugin-gtk3


Now we need to create a new <code>smb.conf</code> from the template configuration file. In the terminal, enter:


cp /etc/samba/smb.conf.default /etc/samba/smb.conf
===Dolphin - KDE/plasma===


Open the newly created <code>smb.conf</code> in a text editor. In the terminal, enter:
pamac install samba kdenetwork-filesharing manjaro-settings-samba


nano /etc/samba/smb.conf
Replace <code>nano</code>with the name of your preferred text editor.


To make usershares possible we need to add the following parameters under section <code>[global]</code>:
==Finishing Up==


  usershare path = /var/lib/samba/usershare
Once you have installed the required packages for your file manager you should '''reboot''' to start the services and let the group changes take effect.
  usershare max shares = 100
  usershare allow guests = yes
  usershare owner only = yes


Approximately halfway in the <code>[global]</code> section is the parameter <code>security = user</code>. Find this line and add the following immediately after:


map to guest = bad user
=Troubleshooting=


This line makes it possible for users without a "proper username" to still connect to a share.


Save the <code>smb.conf</code> file with CTRL+O and close nano with CTRL+X.
==User Accounts==


== Post-install (Users and Groups) ==
If you are getting permission denied when connecting to a new share, one common cause of this is that samba does not have access to Linux user passwords by default.  To remedy this, create a samba password for your user account:
sudo smbpasswd -a theusername


Now add your user to the sambashare group. Replace <code><username></code> with your real username. In the terminal, enter:


usermod -a -G sambashare <username>
This will create a password for the user.


We still need to enable the samba service. In the terminal, enter:


systemctl enable smb nmb
==User Doesn't have Rights to Create Shares==


  systemctl start smb nmb
If you get an error that you don't have rights to create shares ensure that you user account has been added to the [[System_Maintenance#Groups|group]] sambashare. After modifying groups it is required to logout for the changes to take effect.


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.


== Sharing In The Home Directory ==


To be able to share directories in your home (<code>/home/<username></code>) you also need to add new permissions to your home (<code>/home/<username></code>). Replace <code><username></code> with your own username. In the terminal, enter:
==Firewall==


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 <code>/home/<username></code>. 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.
If you are connection connection denied errors make sure you have allowed access through your firewall. See [[Firewalls|the firewall wiki article]] for more details.




== See Also ==
=See Also=
* The [https://www.samba.org/ Samaba Project]
* The [https://wiki.archlinux.org/index.php/Samba Arch Wiki] Samba Page


* '''[https://classicforum.manjaro.org/index.php?topic=11810.msg146682#msg146682 Old thread for Thunar Users]'''
* '''[https://classicforum.manjaro.org/index.php?topic=16833.0 Old forum discussion on sharing /home/]'''


[[Category:Contents Page]]
[[Category:Contents Page]]
Anonymous user