Share Folders using Samba in Home Network with Mint 21

Write tutorials for Linux Mint here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials, start your own topic in the appropriate sub-forum instead. Before you post please read how to get help
Post Reply
altair4
Level 20
Level 20
Posts: 10984
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: viewtopic.php?f=42&t=326160

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.
Last edited by altair4 on Mon Nov 07, 2022 7:43 am, edited 4 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: 10984
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: 10984
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

suso 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.
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: 547
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: 10984
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: 547
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: 10984
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: 547
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: 547
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: 10984
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 5
Level 5
Posts: 573
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: 130
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 winblows in the enterprise I have finally had enough - I see enough Winblows 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 Winblows 11 - they have driven me away. I want to convert all Winblows stuff to Linux before 2025 when Winblows 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 winblows 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: 10984
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.
Post Reply

Return to “Tutorials”