Share Folders using Samba in Home Network with Mint 21

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

Share Folders using Samba in Home Network with Mint 21

PART 1: Setting up the Samba server

[1] Install samba

Code: Select all

sudo apt install samba
[2] To make it "discoverable" ( Explorer > Network > Server ) and accessible ( Explorer > Network > Server > Share ) to WIndows 7 and Up:

Install wsdd:

Code: Select all

sudo apt install wsdd
Make sure it's running:

Code: Select all

sudo service wsdd status
Win8, 10, 11 can also connect to the server using it's mDNS host name ( hostname with a .local attached at the end):
\\hostname.local

[3] To make it "discoverable" ( Finder > Network > Server ) and accessible ( Finder > Network > Server > Share ) to MacOS:

Install avahi - it may already be installed.

Code: Select all

sudo apt install avahi-daemon
Make sure it's running:

Code: Select all

sudo service avahi-daemon status
You can also use Connect to Server in Finder using the mDNS - Bonjour - name:
smb://hostname.local

[4] Now the problem child - the Gnome based Linux samba client.
( Gnome, XFCE, MATE, Cinnamon, maybe others ... )

There appears to be multiple bugs ( like this one https://bugs.launchpad.net/gvfs/+bug/1828107 ) in the gvfs backend of all these desktops that makes discovery problematic. This does not mean you can't access your share from them.

There are ways around this problem:

Bypass the bugs by asking for the server and it's share explicitly - in the file manager or Connect to Server with one of these:
smb://hostname/sharename
smb://hostname.local/sharename
smb://192.168.0.101/sharename.


OR, Do a cifs mount: Automount Samba Shares with CIFS

OR, Ignore the security warnings about enabling SMB1 on the server and override the default setting:

Edit /etc/samba/smb.conf
Right under the workgroup = WORKGROUP line add this one:
server min protocol = NT1
Then reboot the box - yes, reboot the box.

Note: As Samba itself has stated in it's recent releases SMB1 will eventually go away:
We take this opportunity to remind that we have deprecated and disabled by default, but not removed, the whole SMB1 protocol since Samba 4.11.
....
Eventually SMB1 as a whole will be removed,...
I would get used to living without it.

For those who use ufw please see my firewall reference here: viewtopic.php?p=2336472#p2336472
Last edited by altair4 on Sat Mar 16, 2024 8:11 am, edited 6 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

PART 2: Creating a Samba Share Using Samba Directly
Creating a Samba share of a Folder

This is an alternative to creating a samba share from Mint's file managers. It uses samba directly which provides a more coherent and configurable environment than that of the file manager.

Edit /etc/samba/smb.conf

And at the bottom of the file create a share definition to the folder you want to share.

This example shows a simple guest accessible share of my Public folder:

Code: Select all

[Public]
path = /home/altair/Public
read only = no
force user = altair
guest ok = yes
Changing guest ok = yes to guest ok = no will force a prompt for credentials on the client.

Make sure you added your user names to the samba password database. For example:

Code: Select all

sudo smbpasswd -a altair
This example restricts which users or groups of users can access the share:

Code: Select all

[Public]
path = /home/altair/Public
read only = no
force user = altair
valid users = altair, mork, mindy, @plugdev
Only altair, mork, mindy, and members of the plugdev group can gain access to the share.

Save the file then restart smbd:

Code: Select all

sudo service smbd restart
I should note that should you decide to use this method it's best not to use the file manager method - on the same shared folder - at the same time - since the two share definitions will not likely match.
Last edited by altair4 on Sun Jul 17, 2022 7:26 am, edited 3 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

Part 3: Creating a Samba Share from Nemo

I personally recommend creating shares using samba directly as outlined in Part 2. Nemo does allow a user to create shares from folders he owns as an alternate method however. If you choose to do so you may still have to modify smb.conf

Ubuntu changed the default permissions on home folders from 755 to 750 so only the owner of the home folder can access anything under it. This is true locally and across the network.

If you are using Cinnamon and try to create a share of your Public folder for example through Nemo you will get this warning:
The permissions for /home/altair
prevent other users from accessing this share
It will still create the share but access for anyone other than you will not be possible.

There are 4 ways around this problem:

[1] You can force everyone on your lan to use your username.

When you create the share do not select:
Allow others to create and delete files
Guest access

Your clients will have to provide a user name and password to gain access so they would use your user name and samba password which you create using the smbpasswd command:

Code: Select all

sudo smbpasswd -a altair
You can set the samba password to something other than your login password.

[2] Or, Change the permissions to your home folder back to what it was:
chmod o+rx $HOME
Or at least allow it to be traversed:
chmod o+x $HOME

[3] Or, Force the client user to appear to be you by adding a "force user" directive in smb.conf:

Edit /etc/samba/smb.conf and under the workgroup = WORKGROUP line add this one:

Code: Select all

force user = altair
Using your own user name instead of altair.

Then restart smbd: sudo service smbd restart

You will probably have to do this anyway to resolve permissions issues.

[4] Or, Create the share directly in smb.conf as illustrated in Part 2 above.
Last edited by altair4 on Thu Sep 14, 2023 9:52 am, edited 1 time in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
urdrwho
Level 5
Level 5
Posts: 566
Joined: Mon Mar 13, 2017 11:13 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by urdrwho »

Thank you for this write-up.

But seriously, I was talking to one of my clients and they were talking about IT costs. I was suggesting Linux. Now could you imagine the havoc of a small office trying to go this route and having to use terminal commands. They'd throw shoes at me and be back on Windows in one minute.

But I dabble. I didn't get a response when I tried to install wsdd and it isn't even in the package manager?
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

wsdd is very much in the repository:
tester@vmint21cinn:~$ sudo apt show wsdd
[sudo] password for tester:
Package: wsdd
Version: 2:0.7.0-1
Priority: optional
Section: universe/net
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthew Grant <matt@mattgrant.net.nz>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 115 kB
Depends: python3 (>= 3.7)
Homepage: https://github.com/christgau/wsdd
Download-Size: 32.9 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: Python Web Services Discovery Daemon, Windows Net Browsing
This daemon is used to announce Linux Hosts to Windows 7+ computers for
use in their File Manager network browsing, by using the Windows
Services Discovery Protocol.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
urdrwho
Level 5
Level 5
Posts: 566
Joined: Mon Mar 13, 2017 11:13 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by urdrwho »

I'm back.

Ok. I need to go to git and get it. Right?

I see I need to do some work to get it into synaptic.

altair4 wrote: Wed Aug 10, 2022 11:20 am wsdd is very much in the repository:
tester@vmint21cinn:~$ sudo apt show wsdd
[sudo] password for tester:
Package: wsdd
Version: 2:0.7.0-1
Priority: optional
Section: universe/net
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthew Grant <matt@mattgrant.net.nz>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 115 kB
Depends: python3 (>= 3.7)
Homepage: https://github.com/christgau/wsdd
Download-Size: 32.9 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: Python Web Services Discovery Daemon, Windows Net Browsing
This daemon is used to announce Linux Hosts to Windows 7+ computers for
use in their File Manager network browsing, by using the Windows
Services Discovery Protocol.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

It's already in synaptic.

You do realize you are posing in a HowTo about Mint 21, right?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
urdrwho
Level 5
Level 5
Posts: 566
Joined: Mon Mar 13, 2017 11:13 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by urdrwho »

Hm? I always take the easy route first and checked synaptic. It might be in yours but it's not in mine.
And yes I know I'm in Mint 21 but this is really a network issue. Probably should go over there but I was led her about Samba.
I don't need Windows to pull files from Linux, I need to pull files from my windows network folders.
This worked fine for years. And then several months ago a Samba update changed all that.
Screenshot from 2022-08-10 16-10-20.png
altair4 wrote: Wed Aug 10, 2022 3:56 pm It's already in synaptic.

You do realize you are posing in a HowTo about Mint 21, right?
urdrwho
Level 5
Level 5
Posts: 566
Joined: Mon Mar 13, 2017 11:13 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by urdrwho »

Oh man this is too much stress. Two hours ago I heard another friend died, that makes 3 in the past 60 days. I don't feel like playing github, repo, why isn't samba working. Going back to MX 21 where it still works. i'D LOVE TO COME BACK TO MINT BUT .........................
Last edited by urdrwho on Wed Aug 10, 2022 4:51 pm, edited 1 time in total.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

[1] Can't help you with wsdd not showing up in synaptic. It's there by default.

[2] This is a HowTo on setting up a simple samba home server for other systems to access. Not a HowTo on accessing someone else's shares - with the exception for the Linux / gnome based smb client accessing this server which I reference in item [4] of Part 1.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
axrusar
Level 7
Level 7
Posts: 1512
Joined: Sat Jan 30, 2021 5:30 pm

Re: Share Folders using Samba in Home Network with Mint 21

Post by axrusar »

THANK YOU Altair4 for this tutorial. Will keep it handy in my USEFUL links arsenal :D
Linux Mint Una Cinnamon 20.3 Kernel: 5.15.x | Quad Core I7 4.2Ghz | 24GB Ram | 1TB NVMe | Intel Graphics
Image
thisweb
Level 1
Level 1
Posts: 4
Joined: Thu Jul 02, 2020 6:12 pm

Re: Share Folders using Samba in Home Network with Mint 21

Post by thisweb »

Really helpful post Altair4. The permissions error in Cinnamon/Nemo has been driving me mad all day, turns out to be an upstream permissions change in Ubuntu, easy fix but I would never have known that. Thank you so much Altair4!
antcj
Level 3
Level 3
Posts: 148
Joined: Thu Jun 28, 2012 11:17 pm

Re: Share Folders using Samba in Home Network with Mint 21

Post by antcj »

Altair thank you as usual.

But i have to ask, why isn't networking ie samba and all components required, part of the package?


For a brand new user this is a big killer.
jryodamin
Level 1
Level 1
Posts: 12
Joined: Wed Jul 29, 2020 5:27 pm

Re: Share Folders using Samba or CIFS (I do not really care as long as it works) in Home Network with Mint 21

Post by jryodamin »

Yes, I agree this is a deal breaker - I am coming from windows 10 where networking just works - to Linux (a network OS my a$$) where networking kinda sorta sometimes maybe works if you rtfm for 8 years, become a Linux guru and programmer so you can program your own network clients and the hand of god touches your PC 18.33 times every 14.68 days....

All joking aside _- I started as a hobbyist Red Hat 2.0 back in 1999, 2001?? I dunno somewhere around there and Linux networking hasn't improved much since then. Not when it comes to accessing other OS shares that is. However, after 28 years of supporting Windows in the enterprise I have finally had enough - I see enough Windows problems at work to fill me for the rest of my life and NOW MS is going to demand everyone have a MS account to sign onto Windows 11 - they have driven me away. I want to convert all Windows stuff to Linux before 2025 when Windows 10 support ends. I have that long to start learning this stuff all over again after about 20 years being away from Linux. A LOT has changed - except the miserable experience accessing Windows shares and THEY are CIFS now ffs - whats up MINT?

I have this in fstab: I have entered the username/password in my fstab

//192.168.xxx.xxx/media/media/dadbackup /mnt/dadbackup cifs username=<name>,password=<password>,uid=1000,dir_mode=0777,file_mode=0777,nounix,noauto,x-systemd.automount 0 0

After I restart daemon (sudo systemctl daemon-reload) and remote fs (sudo systemctl restart remote-fs.target) I see it in the /mnt/dadbackup but accessing it reveals no contents in dadbackup

there is LOTS in dadbackup

If anyone can help that'd be great :-) cause I am one head bang against keyboard before I install samba again....which everyone tells me is no good anymore but it's the only thing that seems to work consistently.

thanks a bunch ahead of time.
jryodamin
Level 1
Level 1
Posts: 12
Joined: Wed Jul 29, 2020 5:27 pm

Re: Share Folders using Samba in Home Network with Mint 21

Post by jryodamin »

Just after I posted that I found something called Places->"connect to" and 30 seconds later I am browsing my windows share...doh!

The ones I mounted using fstab are still not connecting though, if anyone can give me a hand I'd be grateful.
If I can get access to the rest via the file system I could then setup some backups and 1 step closer to ditching Windows.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

I can't reproduce your issue although I have no idea what OS you are trying to connect to.

I will say however that this part of your fstab declaration is .... unusual: //192.168.xxx.xxx/media/media/dadbackup

The syntax is //server/share

If the shared resource on the server os is labeled dadbackup the correct syntax would be: //192.168.xxx.xxx/dadbackup

If the shared resource is labeled media it's //192.168.xxx.xxx/media

It's problematic to use the full path of the shared folder on the server from the client if that is what /media/media/dadbackup is referencing.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

Re: Share Folders using Samba or CIFS (I do not really care as long as it works) in Home Network with Mint 21

Post by SaintDanBert »

jryodamin wrote: Sun Oct 02, 2022 1:39 am {snip}
All joking aside _- I started as a hobbyist Red Hat 2.0 back in 1999, 2001?? I dunno somewhere around there and Linux networking hasn't improved much since then. Not when it comes to accessing other OS shares that is.
{snip}
Computer networking is not a commodity service. In most cases today, you are trying to connect and interoperate two or more workstations that were seldom designed to work with each other. Trust Me it is a lot easier using the internet protocols than most of the {usually proprietary} protocols that came before.

I, too, started about the same time that you did. Where "Windows Network Sharing" is concerned, it has been a mess and remains a mess for a variety of reason starting with SMB1. I built linux-based industrial instruments that used shares with windows workstations in the labs to read configurations and write results. Windows® kept moving the goal posts in all sorts of ways. Eventually, we deployed an NFS server on windows and our constant tinker stopped.

We then had issues with "auto mounting" but we handled them on the instruments.

Just my opinion...
Cheers,
~~~ 0;-Dan
NorthantsPete
Level 1
Level 1
Posts: 2
Joined: Thu Mar 02, 2023 4:12 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by NorthantsPete »

works fine on unix aka Mac.

So its not unix/linux, its the implementation and classic "oh you didnt edit XYZ? dummy!"


if the optiont o share is there it should work without extra editing of root config files... just share the damn thing - why windows for workstations took off, no config!
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Share Folders using Samba in Home Network with Mint 21

Post by altair4 »

A lot of users seem to be using the ufw firewall in Linux and they are wondering why WSDD fails to result in Windows being able to "discover" the samba server in Explorer.

Unlike the samba package that comes with a ufw application profile that allow you to do a sudo ufw allow samba, WSDD is missing one. You can create your own if you want:

Create a file: /etc/ufw/applications.d/wsdd

Copy and paste this into it:

Code: Select all

[wsdd]
title=Windows Services Discovery Protocol
description=Used to announce Linux Hosts to Win7+ computers while network browsing in their File Managers.
ports=3702/udp|5357/tcp
Save the file.

Then to allow samba through the firewall issue these two commands:

Code: Select all

sudo ufw allow samba

Code: Select all

sudo ufw allow wsdd
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
lsemmens
Level 11
Level 11
Posts: 3951
Joined: Wed Sep 10, 2014 9:07 pm
Location: Rural South Australia

Re: Share Folders using Samba in Home Network with Mint 21

Post by lsemmens »

Be Warned! Even after following all of the above, when attempting to create said shares, you may well still get a "the permissions of /home/your folder prevent other users from accessing your share" if you continue anyway, Samba does update the permissions and all is well. I wasted an hour today trying to "fix" this.
Fully mint Household
Out of my mind - please leave a message
Post Reply

Return to “Tutorials”