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

imported>Excalibur1234
(this was created for r_a_trip and slightly modified by me.)
 
(Marked this version for translation)
 
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
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.
<languages/>
__TOC__


<translate>
=Accessing SMB Shares from the File Manager= <!--T:1-->


First we need to install a few packages. Open a terminal and become root:
<!--T:2-->
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 Manjaro editions but if you need to install it you can so with:
pamac install gvfs-smb


su


Install samba, nautilus-share and gvfs-smb. If you use a different file manager, please install the corresponding sharing package for your file manager instead of nautilus-share. In the terminal, enter:
=Sharing Files from the File Manager= <!--T:3-->


pacman -S samba nautilus-share gvfs-smb
<!--T:4-->
The following will guide you through setting up user sharing with Samba so that you can use your file manager to share folders.


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>)
== Installation == <!--T:5-->
In the terminal, enter:


  mkdir -p /var/lib/samba/usershare
<!--T:6-->
Depending on which file manager you use there are different packages to install. Please reference the appropriate section for your file manager.


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:
<!--T:7-->
The {{ic|manjaro-settings-samba}} package will install a basic config and enable the file sharing services.  The whole process is nicely automated.


groupadd sambashare


We need to make user <code>root</code> owner of both the usershares directory and the sambashare group.
===Nemo - Cinnamon=== <!--T:8-->


In the terminal, enter:
<!--T:9-->
pamac install nemo-share manjaro-settings-samba


chown root:sambashare /var/lib/samba/usershare


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.
===Nautilus - Gnome/Budgie=== <!--T:10-->
In the terminal, enter:


  chmod 1770 /var/lib/samba/usershare
  <!--T:11-->
pamac install nautilus-share manjaro-settings-samba


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 <code>smb.conf</code> from the template configuration file. In the terminal, enter:
===Caja - MATE=== <!--T:12-->


  cp /etc/samba/smb.conf.default /etc/samba/smb.conf
  <!--T:13-->
pamac install caja-share manjaro-settings-samba


Open the newly created <code>smb.conf</code> in a text editor. In the terminal, enter:


nano /etc/samba/smb.conf
===Thunar - XFCE=== <!--T:14-->
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>:
<!--T:15-->
pamac install thunar-shares-plugin-gtk3


  usershare path = /var/lib/samba/usershare
  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:
===Dolphin - KDE/plasma=== <!--T:16-->


  map to guest = bad user
  <!--T:17-->
pamac install samba kdenetwork-filesharing manjaro-settings-samba


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.
==Finishing Up== <!--T:18-->


Now add your user to the sambashare group. Replace <code><username></code> with your real username. In the terminal, enter:
<!--T:19-->
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.


usermod -a -G sambashare <username>


We still need to enable the samba service. In the terminal, enter:
=Troubleshooting= <!--T:20-->


systemctl enable smbd nmbd
==Protocol version== <!--T:21-->


systemctl start smbd nmbd
<!--T:22-->
Since samba 4.11.0 released on 2019-09-17, the very old Windows NT protocol is disabled by default because of serious security issues, so if you connect to:
* a supported Windows version
* a supported Linux Samba server
* a supported NAS appliance


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.  
<!--T:23-->
Please upgrade these to the latest version and disable the NT1 protocol on these servers if not done automatically.


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:
<!--T:24-->
If you connect to:
* an unsupported Windows version
* an unsupported NAS


chmod 701 /home/<username>
<!--T:25-->
Please turn off file sharing towards the Internet and know that malicious users on your LAN (unless isolated in a guest network) will be able to access all local NT1 shares with full control.


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.
==User Accounts== <!--T:26-->


<!--T:27-->
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


A forum thread discussing this subject is available here: [https://forum.manjaro.org/index.php?topic=16833.0]
 
<!--T:28-->
This will create a password for the user.
 
 
==User Doesn't have Rights to Create Shares== <!--T:29-->
 
<!--T:30-->
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.
 
 
 
==Firewall== <!--T:31-->
 
 
<!--T:32-->
If you are getting "connection denied" errors make sure you have allowed access through your firewall.  See [[Firewalls|the firewall wiki article]] for more details.
 
=See Also= <!--T:33-->
* The [https://www.samba.org/ Samba Project]
* The [https://wiki.archlinux.org/index.php/Samba Arch Wiki] Samba Page
</translate>
 
[[Category:Contents Page{{#translation:}}]]

Latest revision as of 18:58, 7 September 2021

Other languages:
English

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 gvfs-smb. This is present by default in most Manjaro editions but if you need to install it you can so with:

pamac install gvfs-smb


Sharing Files from the File Manager

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


Installation

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


The manjaro-settings-samba package will install a basic config and enable the file sharing services. The whole process is nicely automated.


Nemo - Cinnamon

pamac install nemo-share manjaro-settings-samba


Nautilus - Gnome/Budgie

pamac install nautilus-share manjaro-settings-samba


Caja - MATE

pamac install caja-share manjaro-settings-samba


Thunar - XFCE

pamac install thunar-shares-plugin-gtk3


Dolphin - KDE/plasma

pamac install samba kdenetwork-filesharing manjaro-settings-samba


Finishing Up

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.


Troubleshooting

Protocol version

Since samba 4.11.0 released on 2019-09-17, the very old Windows NT protocol is disabled by default because of serious security issues, so if you connect to:

  • a supported Windows version
  • a supported Linux Samba server
  • a supported NAS appliance

Please upgrade these to the latest version and disable the NT1 protocol on these servers if not done automatically.

If you connect to:

  • an unsupported Windows version
  • an unsupported NAS

Please turn off file sharing towards the Internet and know that malicious users on your LAN (unless isolated in a guest network) will be able to access all local NT1 shares with full control.

User Accounts

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


This will create a password for the user.


User Doesn't have Rights to Create Shares

If you get an error that you don't have rights to create shares ensure that you user account has been added to the group sambashare. After modifying groups it is required to logout for the changes to take effect.


Firewall

If you are getting "connection denied" errors make sure you have allowed access through your firewall. See the firewall wiki article for more details.

See Also