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

From Manjaro
Jump to navigation Jump to search
imported>Excalibur1234
(this was created for r_a_trip and slightly modified by me.)
 
(→‎Troubleshooting: Added Protocol section because this is still the hottest problems on the forum)
 
(10 intermediate revisions by 7 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.
+
__TOC__
  
  
First we need to install a few packages. Open a terminal and become root:
+
=Accessing SMB Shares from the File Manager=
  
  su
+
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
  
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:
 
  
pacman -S samba nautilus-share gvfs-smb
+
=Sharing Files from the File Manager=
  
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.
+
The following will guide you through setting up user sharing with Samba so that you can use your file manager to share folders.
  
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>)
 
In the terminal, enter:
 
  
mkdir -p /var/lib/samba/usershare
+
== Installation ==
  
We have now added the usershares directory in <code>/var/lib/samba</code>.
+
Depending on which file manager you use there are different packages to install.  Please reference the appropriate section for your file manager.
  
Next we need to create the sambashare group. In the terminal, enter:
 
  
  groupadd sambashare
+
The {{ic|manjaro-settings-samba}} package will install a basic config and enable the file sharing services. The whole process is nicely automated.
  
We need to make user <code>root</code> owner of both the usershares directory and the sambashare group.
 
  
In the terminal, enter:
+
===Nemo - Cinnamon===
  
  chown root:sambashare /var/lib/samba/usershare
+
  pamac install nemo-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
+
===Nautilus - Gnome/Budgie===
  
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 nautilus-share manjaro-settings-samba
  
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
+
===Caja - MATE===
  
Open the newly created <code>smb.conf</code> in a text editor. In the terminal, enter:
+
pamac install caja-share 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>:
+
===Thunar - XFCE===
  
  usershare path = /var/lib/samba/usershare
+
pamac install thunar-shares-plugin-gtk3
  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
+
===Dolphin - KDE/plasma===
  
This line makes it possible for users without a "proper username" to still connect to a share.
+
pamac install samba kdenetwork-filesharing manjaro-settings-samba
  
Save the <code>smb.conf</code> file with CTRL+O and close nano with CTRL+X.
 
  
Now add your user to the sambashare group. Replace <code><username></code> with your real username. In the terminal, enter:
+
==Finishing Up==
  
usermod -a -G sambashare <username>
+
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.
  
We still need to enable the samba service. In the terminal, enter:
 
  
systemctl enable smbd nmbd
+
=Troubleshooting=
  
systemctl start smbd nmbd
+
==Protocol version==
  
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.
+
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
  
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:
+
Please upgrade these to the latest version and disable the NT1 protocol on these servers if not done automatically.
  
chmod 701 /home/<username>
+
If you connect to:
 +
* an unsupported Windows version
 +
* an unsupported NAS
  
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.
+
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==
  
A forum thread discussing this subject is available here: [https://forum.manjaro.org/index.php?topic=16833.0]
+
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 [[System_Maintenance#Groups|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 [[Firewalls|the firewall wiki article]] for more details.
 +
 
 +
=See Also=
 +
* The [https://www.samba.org/ Samba Project]
 +
* The [https://wiki.archlinux.org/index.php/Samba Arch Wiki] Samba Page
 +
 
 +
 
 +
[[Category:Contents Page]]

Latest revision as of 11:37, 10 May 2021


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