Windows10 and Samba File Sharing

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
Post Reply
altair4
Level 20
Level 20
Posts: 11453
Joined: Tue Feb 03, 2009 10:27 am

Windows10 and Samba File Sharing

Post by altair4 »

Windows 10 and Samba File Sharing
Note: This Howto has 3 parts.

[Part 1] Connecting to a Linux Samba Server from Win10

Samba is used to connect Linux to Windows and has traditionally used NetBIOS to discover hosts by name ( netbios name ) but Win10 made some changes that affect how this works. On the client side ( accessing Linux from Win10 ):
Windows 10 Home and Windows 10 Professional still contain the SMBv1 client by default after a clean installation. If the SMBv1 client is not used for 15 days in total (excluding the computer being turned off), it automatically uninstalls itself.
SMBv1 and browsing for netbios hosts in Explorer are linked. You can't have one without the other so it will never see your Linux samba server in Explorer.

You can still access the Linux machine by name or ip address but it has to be done explicitly in Explorer:
By name: \\mint-host-name
By ip address \\mint-ip-address

Another change Win10 made is that it can now use mDNS which Linux and MacOS use:

[Part 1a] Connecting to a Linux Samba server with an mDNS qualified host name works out of the box in Win10:

Open Run in Windows ( Windows Key + R ) and enter the Linux mDNS qualified host name like this:

Code: Select all

\\mint-host-name.local
For example:
Connect-from-Run.png
Windows Explorer will instantly open up to that location:
Explorer-Result-From-Run.png
And you can map a particular share at that point if you wish: Right click a shared folder > Map network drive:
Map-a-shared-folder.png

[Part 1b] WSD = WS-Discovery

There is another option. Windows replaced NetBIOS years ago with WSD. There is no implementation of WSD in Samba yet but there is a way to implement it in Linux thanks to someone over at github: https://github.com/christgau/wsdd

You can use that to enable WSD on your box so that Win10 can discover it without the use of NetBIOS or SMBv1:

EDIT: If you are using Mint 21 enabling WS-Discovery manually is no longer required. It's now an installable package:

Code: Select all

sudo apt install wsdd
This is no longer required in Mint21:
Download the folder:

Code: Select all

wget https://github.com/christgau/wsdd/archive/master.zip
UnZip it:

Code: Select all

unzip master.zip
Rename the python script:

Code: Select all

sudo mv wsdd-master/src/wsdd.py wsdd-master/src/wsdd
Copy it to bin:

Code: Select all

sudo cp wsdd-master/src/wsdd /usr/bin
Copy the systemd service file to /etc/systemd/system:

Code: Select all

sudo cp wsdd-master/etc/systemd/wsdd.service /etc/systemd/system
Create a missing file:

Code: Select all

sudo touch /etc/default/wsdd
Reload the service:

Code: Select all

sudo systemctl daemon-reload
Start the service:

Code: Select all

sudo systemctl start wsdd
Enable the service so it starts at boot:

Code: Select all

sudo systemctl enable wsdd
That is pretty much it. Win10 will see your Linux machine automatically using WSD.
Last edited by SMG on Mon Dec 19, 2022 12:39 pm, edited 27 times in total.
Reason: Unlocked: Tutorial is still being updated.
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: 11453
Joined: Tue Feb 03, 2009 10:27 am

Re: Windows10 and Samba File Sharing

Post by altair4 »

[Part 2] Connecting to a Win10 box from Linux

Microsoft made another change to SMBv1 on the server side:
Windows 10 Home and Windows 10 Professional no longer contain the SMBv1 server by default after a clean installation.
In the past Ubuntu could only access the network using SMB1 so it made a change that created this bug:
https://bugs.launchpad.net/ubuntu/+sour ... mments=all
That bug was fixed but it created another bug:
https://bugs.launchpad.net/gvfs/+bug/1828107

All of this results in you being able to discover the Win10 box but unable to access it.

But just like in Windows you can still access it's shares without adjusting the client max protocol but have to do so explicitly in nemo and you have to specify a share name because of a bug in gvfs:

By name: smb://win10-host-name/share-name
By ip address: smb://win10-ip-address/share-name
Note: Nemo needs to be closed and reopened before using the above.

[Part 2a] Connecting to a Win10 box with its mDNS qualified host name is also possible.

This section is no longer required:
Update:: Windows made this a little easier to set up in Win10:
Update2:: The last few install required no changes to the firewall. Works by default
Control Panel > Windows Defender Firewall > Allow an app or feature through Windows Defender Firewall > Change Settings. Then enable:

File and Printer Sharing ---> Private
mDNS -- Private

This should no longer be necessary:
Right Click the Start Button > Control Panel > System and Security > Windows Firewall > Advanced Settings > Inbound Rules > New Rule

Rule Type: Port
Protocol: UDP
Specific local ports: 5353
Action: Allow the connection
Profile: Private
Name: Allow mDNS for Samba on Private Network
*** On Linux open you your file manager and connect to the share using the Windows mDNS qualified host name and a share name:

Code: Select all

smb://vwin10.local/shared
*** Or you can use Alt+F2 to open run and enter:

Code: Select all

nemo smb://vwin10.local/shared
Win10 / Linux samba file sharing may work for you without all this but if you have issues with it this mDNS method is another way.
Last edited by altair4 on Sun Feb 13, 2022 3:27 pm, edited 18 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: 11453
Joined: Tue Feb 03, 2009 10:27 am

Re: Windows10 and Samba File Sharing

Post by altair4 »

[Part 3] Providing Microsoft Account credentials when accessing a Win10 shared Folder.

If you installed Windows using a Microsoft Account rather than a local account you may have noticed that there's a problem with passing a username and password to Windows to access it's shares. You have two options:

[1] You can pass the Microsoft Account credentials you just have to do it a different way:

As an example let's say your Microsoft login to Win10 is: altair@something.com

When you connect to the shared folder from Linux you need to pass credentials this way:
Win10SMBCredentials.png
Username = altair
Domain = something.com ( or hotmail.com or live.com or whatever.com )
Password = your Win10 login password

And a manual mount takes a form something like this:

Code: Select all

sudo mount -t cifs //vwin10.local/shared /TestCIFSMount -o username=altair,password=win10password,domain=something.com,uid=1000

[2] Create a separate local user in Win10 for use only with samba:

Right click the Start Button > Computer Management > Local Users and Groups > Users > More Actions > New User:

Username: smbuser
Password: smbuserpw
Unselect: User must change password at next login
Select: User cannot change password
Select: Password never expires

Then when Windows asks for credentials pass smbuser's credentials.
Last edited by altair4 on Sun Jun 19, 2022 2:55 pm, 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.
kwisher

Re: Win10, Linux, mDNS, and Samba File Sharing

Post by kwisher »

Great post :) Thanks for the info!
DEcosse

Re: Win10, Linux, mDNS, and Samba File Sharing

Post by DEcosse »

AMAZING post - Thank you!!!!

No matter what I tried, I could not access my Win10 shares - my access was simply not recognized
By applying part 3 [2} and creating another user, all is good!
Mitch26
Level 1
Level 1
Posts: 16
Joined: Mon Aug 24, 2015 5:13 am

Re: Win10, Linux, mDNS, and Samba File Sharing

Post by Mitch26 »

Hi, I can connect to the files on my windows PC from my LinuxMint Rafaela PC but not the reverse. I have tried all the possible solutions given in the posts of this topic without success. I have left the smb.conf file as I had found it. Any other suggestions ?
altair4
Level 20
Level 20
Posts: 11453
Joined: Tue Feb 03, 2009 10:27 am

Re: Win10, Linux, mDNS, and Samba File Sharing

Post by altair4 »

Yes, Start a new and separate topic in the Networking section of the forum since it has nothing to do with this HowTo.

When you do post the output of these commands:

Code: Select all

testparm -s

Code: Select all

net usershare info --long

Code: Select all

sudo service avahi-daemon status
And tell us what DE you are using: Cinnamon, MATE, XFCE, or the other one .... um .... KDE.

And tell us what error message Windows is giving you when you try to access the share.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
terry_dwyer
Level 3
Level 3
Posts: 108
Joined: Sat Nov 07, 2020 2:15 am
Location: West Aus.

Re: Windows10 and Samba File Sharing

Post by terry_dwyer »

I just want to say a sincere thank you for the wsdd info. I did exactly as you instructed and it worked like a charm on 2 older linux boxes. the first being just a server for storing backups and the other one hosting plex and all the other bits and pieces it requires. After installing wsdd, I can see the host machine and the fileserver (running under docker) as well. I thought there would be all sorts of problems with the docker container, but surprisingly it wasn't an issue.

Now I can go and uninstall avahi (which didn't work)

Much appreciated,

Terry
altair4
Level 20
Level 20
Posts: 11453
Joined: Tue Feb 03, 2009 10:27 am

Re: Windows10 and Samba File Sharing

Post by altair4 »

I just want to say a sincere thank you for the wsdd info. I did exactly as you instructed and it worked like a charm on 2 older linux boxes.
It is my hope that one day wsdd is either incorporated within Samba itself or at least offered as a package in the Ubuntu or Debian repositories so folks wouldn't have to install it themselves.
Now I can go and uninstall avahi (which didn't work)
I wouldn't uninstall it. It's a dependency of CUPS and perhaps other things. It's not really taking up that many resources but if it is an issue in your circumstance I would just prevent it from running the next time you reboot:

Code: Select all

sudo systemctl mask avahi-daemon
Should you later decide you need it you can unmask it:

Code: Select all

sudo systemctl unmask avahi-daemon
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
terry_dwyer
Level 3
Level 3
Posts: 108
Joined: Sat Nov 07, 2020 2:15 am
Location: West Aus.

Re: Windows10 and Samba File Sharing

Post by terry_dwyer »

Yes, about being a package... I was astounded after installing it and the surprisingly good results given that nothing else I tried had worked, that it hadn't been packaged up with a big banner saying "THIS ACTUALLY WORKS".

Btw, appreciation and thanks to the author.

Given all the things I'd tried and failed with, especially after having found (using Google) so many people with the same problem who probably still don't have a solution, I thought this would be more well known.

I certainly hope it gets packaged up soon.

[SOLVED]
Lordbiron
Level 1
Level 1
Posts: 1
Joined: Mon Dec 19, 2022 12:29 pm

Re: Windows10 and Samba File Sharing

Post by Lordbiron »

Thanks man, I'm new in Linux world and this tutorial save my life. :D :D :D
Post Reply

Return to “Tutorials”