Linux-Windows Samba Share Problem [SOLVED]

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
atrandum

Linux-Windows Samba Share Problem [SOLVED]

Post by atrandum »

Hello,
I'm new to this forum but have been looking around for a while, but haven't found a solution that's worked for my problem.

I have a Windows 10 PC in my living room, and a desktop with Linux Mint 19 in my office. I've been a Windows person my whole life but my husband wanted to switch to Linux, so we have this problem now - I want to share files between the two computers, but so far have only been able to share folders on the C drive of the Linux computer to the Windows computer.

I went into the Samba configuration file to add a folder share path at the end of the file:

[share]
comment = Ubuntu File Server Share
path = /srv/samba/share
browsable = yes
guest ok = yes
read only = no
create mask = 0755

This is the sample from the Ubuntu manual instructions I found. I replaced the path with the folder I want to share. If it's a folder on the harddrive where Linux is installed it works and the Windows PC can access the folder. If it's a folder on any other harddrive on the same computer (which I want to share the most) or an external harddrive, the share does not work. On the Windows side, it will say "you do not have permission to access this folder." Sometimes it asks me for a username and password, but no matter what I type in, it doesn't work. On the Linux side, when I try to mount the folder in the Network folder in Nautilus, it says "the folder cannot be mounted."

I honestly have been banging my head against the wall with this problem for a month now. I have tried numerous solutions and have been googling for weeks (not an exaggeration unfortunately). I am a complete Linux noob so the learning curb is steep. I tried creating a Samba user and password, configuring the Samba file like adding a permission for Windows support, and the usershares only = false line. I've tried changing the ownership of the secondary harddrive that I want to share many times (e.g. root as owner, or the linux user as owner). I've put Linux and Windows in the same workgroup. I even reformatted the secondary harddrive to ext4 and wiped it using the shred command because it seems like there's a lingering permission issue. So I tried starting from a clean slate for the drive but no luck. I even tried the dreaded chmod 777 command and nothing happened. I tried an external harddrive and a third internal harddrive and no luck.

There are a bunch of other solutions I tried that I can't even remember now. Basically anything I saw online that seemed related, I tried. But I wouldn't put it pass my noob skills that I implemented some solutions incorrectly. I am really at a loss so I would be grateful for any help. If I haven't provided enough details, please let me know what information is needed. Thank you for your time and help.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
deepakdeshp
Level 20
Level 20
Posts: 12341
Joined: Sun Aug 09, 2015 10:00 am

Re: Linux-Windows Samba Share Problem

Post by deepakdeshp »

Please try
viewtopic.php?t=267444
Good luck
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
User avatar
powerwagon75
Level 4
Level 4
Posts: 339
Joined: Sun Feb 28, 2016 4:05 pm
Location: USA

Re: Linux-Windows Samba Share Problem

Post by powerwagon75 »

I can try and offer you a work around if you like.

To get from Windows-to-Linux:
The only MicroSoft I interact with at home is a work laptop, which is fairly locked-down by the business unit. I recently tried the free WinSCP program, (https://winscp.net/eng/download.php) and so far has been working well, with regards to seeing my Linux systems on the Win10 laptop. Once installed and started, to establish a connection you'll need to input the userid@192.168.xxx.xxx--your userid on the Linux system, and the IP address of it. The username box should auto-populate, and enter the password and go. You should get the first time connections notices, select yes to proceed.

For the Linux-to-Linux systems, I just open Nemo, and in the browser line enter sftp://user@192.168.xxx.xxx. You then get a login dialogue pop-up to answer, and you're in.

To get from Linux-to-Windows, I had to edit the /etc/samba/smb.conf file, in this area:

Code: Select all

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP
   client max protocol = SMB3
Those last two lines above are what I needed to make it connect to Windows--without the SMB3 I would just get errors. (Restart after making editing changes to your smb.conf file.)

To login to the Windows laptop from Linux, it seems to want the proper name of the PC; ie, right-click on the lower left menu button, select search, type the word: name, and select View Your PC Name. Look for Device Name, under Device Specifications.

For some reason, even with WinSCP installed, it still doesn't like to be connected to via sftp. So, using the info in the previous paragraph, in Nemo, I type smb://X5-S21xxxx (device name), and it pops up the login box. I type in userid, password, and company DOMAIN name, and it logs in. (in your case, you shouldn't have to change your domain name on your home PCs.) Even as the laptop leaves/returns to the house daily, the Linux machines will jump right back on it when clicked again.

Again, so far I find the WinSCP a handy tool that serves my needs. Its backing up data to the 3TB backup drive in my main tower as I type this. I will start re-synching it once or twice a week now that it is set up.

Edit... I'm not really clear what you're saying when talking about C: and D: drives on your Linux system. Linux does not use the old DOS conventions of alpha-named drives. If you want to get to a secondary, mounted hard drive on your Linux system, from Windows, once connected, browse to the
folder /media/username/, and your mounted media will be listed there. Click on the media folder to open it remotely/access the data.
Image
Custom Antec Outside tower w/Mint 20.2
HP lap w/Mint 20.3
Optiplex 960 "Frankenbox" w/Fedora 39/Mint 19.2/Mint 20.2
Advantech TPC-1551T w/LinuxLite
Acer C720 Chromebook w/GalliumOS
Mac PPC G4 w/Lubuntu
atrandum

Re: Linux-Windows Samba Share Problem

Post by atrandum »

Hello! Thank you so much for the replies!

@deepakdeshp - Thank you for the link! I originally had client max protocol = NT1 so I changed it to client max protocol = SMB3 as the link said but it did not work :( The windows PC says you don't have permission to access, and when I try to access the share through Nautilus > Network to mount the share, it gives me this pop up saying a password is required for the share on localhost. When I try anonymous user, it doesn't work. When I try to enter a registered user (the Linux user or the Windows user), it doesn't work.

@powerwagon75 - Thanks so much for the detailed instructions! I haven't heard of WinSCP before and will try it out! This seems really promising!! Will update once I try.

Edit: just saw your comment on the C and D drives. Sorry, that's just my old habit from Windows. I don't know what the drives are called in Linux, something like sdc1 or something. Basically there's the drive where Linux is installed - the Windows PC can access that drive fine. But Windows cannot access any external harddrive or a separate internal harddrive on that Linux PC. I'll try the WinSCP though!
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: Linux-Windows Samba Share Problem

Post by altair4 »

If it's a folder on the harddrive where Linux is installed it works and the Windows PC can access the folder. If it's a folder on any other harddrive on the same computer (which I want to share the most) or an external harddrive, the share does not work. On the Windows side, it will say "you do not have permission to access this folder."
I betcha it's because the folder you are sharing is in a partition mounted under /media/your-linux-user-name. If it is it's not a samba issue it's a Linux permissions issue since only "your-user-name" can access the folder. That is by design.

One way around this issue is to add an option to /etc/samba/smb.conf. If you plan on creating shares that allow guest access add the following line to smb.conf right under the workgroup = WORKGROUP line with your user name:

Code: Select all

force user = your-linux-user-name
Then restart smbd:

Code: Select all

sudo service smbd restart
I honestly have been banging my head against the wall with this problem for a month now. I have tried numerous solutions and have been googling for weeks (not an exaggeration unfortunately). I am a complete Linux noob so the learning curb is steep. I tried creating a Samba user and password, configuring the Samba file like adding a permission for Windows support, and the usershares only = false line. I've tried changing the ownership of the secondary harddrive that I want to share many times (e.g. root as owner, or the linux user as owner). I've put Linux and Windows in the same workgroup. I even reformatted the secondary harddrive to ext4 and wiped it using the shred command because it seems like there's a lingering permission issue. So I tried starting from a clean slate for the drive but no luck. I even tried the dreaded chmod 777 command and nothing happened. I tried an external harddrive and a third internal harddrive and no luck.
You've done a bunch of stuff nad probalby followed many HowTo's. My suggestion is to post the output of the following commands so we can see how you are set up:

Code: Select all

testparm -s

Code: Select all

net usershare info --long
The error when you try to access WIn10 is confusing. If your Win10 is up-to-date and you ran with client max protocol = NT1 it will fail since Win10 disables SMB1 ( i.e., NT1 ). You don't need to set the max protocol to SMB3 in Mint 19 - it's that way by default.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
atrandum

Re: Linux-Windows Samba Share Problem

Post by atrandum »

@altair4 I can't believe it!! You were totally right. The code you recommended force user = your-linux-user-name WORKED!!!!!!! I can now access the Linux secondary harddrive from the Windows PC!! I literally screamed when I tested it. I don't even understand how a simple line of code worked to solve this problem, and how I never came across this code in my weeks of research. THANK YOU THANK YOU!!!! I can't even explain how happy I am to finally be rid of this problem!!!

@powerwagon75 I did try the WinSCP program, but in both SFTP and FTP mode, the Linux computer rejected the request for connections. I was really bummed until I tried altair4's code haha.

Marking this as solved!! Thank you everyone for taking the time to help especially altair4 - holy crap you saved the day!!
User avatar
powerwagon75
Level 4
Level 4
Posts: 339
Joined: Sun Feb 28, 2016 4:05 pm
Location: USA

Re: Linux-Windows Samba Share Problem [SOLVED]

Post by powerwagon75 »

atrandum,

Glad it worked out for you! For me unfortunately, I have to stick with the WinSCP program, as although "force user = my name" does make it visible on the Windows laptop, I cannot change the domain, (can't switch out of my work domain), therefore can't log in. But it works, and I'm glad yours works the way it supposed to now! Enjoy.

Eric
Image
Custom Antec Outside tower w/Mint 20.2
HP lap w/Mint 20.3
Optiplex 960 "Frankenbox" w/Fedora 39/Mint 19.2/Mint 20.2
Advantech TPC-1551T w/LinuxLite
Acer C720 Chromebook w/GalliumOS
Mac PPC G4 w/Lubuntu
atrandum

Re: Linux-Windows Samba Share Problem [SOLVED]

Post by atrandum »

Thanks Eric! Yes, I'm glad we both found a solution that works :D This has renewed my faith in Linux haha.
Noobie-Wan-Kenobe

Re: Linux-Windows Samba Share Problem [SOLVED]

Post by Noobie-Wan-Kenobe »

To Altair4:

Finally getting back to Mint after a long hiatus. To make a long story short, my mint machine won't bootup after upgrading to the latest kernel. Black Screen of Death after every reboot! :twisted: After trying unsuccesfully to roll back numerous times in Timeshift and trying to boot from an older kernel, I had to re-install Mint 19.1 from scratch. Luckily, I backed up most of my data to another machine. But re-configuring it again took a couple of hours.

Anyways -
I had the same issue on the Windows side, trying to share an external drive (USB thumb) or partition NOT under where Linux is installed.
By adding in "force user = your-linux-user-name" under workgroup in smb.conf - IT WORKED! Holy Moly! I'm now able see those files on my Win7 machine. Thank you! Thank you!
atrandum

Re: Linux-Windows Samba Share Problem [SOLVED]

Post by atrandum »

Glad it worked for you Noobie-Wan-Kenobe!! It still blows my mind that such a simple line of code was the solution to literally weeks of frustration. I'm still thankful to altair4!!
Locked

Return to “Networking”