Help sharing directory between linux and windows (samba?)

Hi, for some reason this wasn’t as trivial as I thought it would be. And I am still learning sys-admin wizardry for fun, so bear with me please.

Here is what I have:

  1. Linux machine with ntfs drives (Debian 9)
  2. Windows machine (W10)

Here is what I need:

  1. To be able to share a folder in the ntfs drive on the linux machine with the windows box.
  2. To be able to share an arbitrary folder in the linux machine such as /home/a_user/share_folder with the windows machine
  3. Make data transfer safe/encrypted (I think samba does this).
  4. Be 100% sure only these two machines can access folders from 1 and 2.

Before you keep reading, am I even going in the right direction should I even be using samba?

Here is what I have tried:

  1. Install samba on linux machine. sudo apt-get install samba

  2. smbpasswd -a samba_user

  3. Add these lines on /etc/samba/smb.conf
    [share_folder]
    path = /home/a_user/share_folder
    available = yes
    valid users = a_user
    read only = no
    browsable = yes
    publlic = yes
    writable = yes

  4. restart service sudo service smbd restart

  5. Make a link to the share on windows
    right click on desktop, shortcut, entered local ip
    \192.168.x.xxx\share_folder

For the ntfs mount the only thing I’ve done differently is that on the samba configuration file has:

path = /dev/sda9/Share (which is my ntfs mount)

instead of

path = /home/a_user/share_folder

Issues:

  1. Permissions, windows doesn’t have write access to the folder at:
    path = /home/a_user/share_folder
    For the local directory share

  2. can’t find folder?
    This one was weirder, maybe its also a permissions issue.
    Windows says:

“windows cannot acces (ip addres)\Share check the spelling of the name. Otherwise, there might be a problem with your network…” … Network name cannot be found error code 0x80070043

You have to mount the disk and then share the mount, you can’t share the disk, certainly not without being root anyway.

Fixed (I think)

I should not have been setting up samba with the drives but the mounts at /media/user

so on the file /etc/samba/smb.conf

I changed paths accordingly ie: path = /media/a_user/drive_mount/Share instead of going to /dev/sda1/Share

Then I had an issue with one mount. I went to /etc/fstab

And removed a umask setting so it defaults to public-ish settings. Setting umask=111 didn’t work for some reason (it would resolve to 666) Maybe it should’ve been 0111, not sure.

Now I am working on making sure that only a specific computer can access these folders.

I literally just did that and it worked! But now I want to know how to prevent any computer that logs in the network from reaching those shared folders. I suppose the samba password is my last line of defense?

Yep, you need to set up authentication and disable guest access. Alternatively is you want to limit access to a specific machine you could configure the firewall to only allow access to samba from that machine.

1 Like

Personally, I always thought that ‘sharing’ in this way is like mixing oil and water.

If one needs to share directories between different OS, then one should have a separate file server.

Looks like you’re on the right path currently. I just want to point out a couple things.

If these are indeed separate machines, there’s no need to dick around with NTFS on Linux. You can use a real file system, and still use Samba to share it over the network with a Windows box. The only time you need NTFS on Linux is when you dual boot between Windows and Linux, and need a partition or entire drive that is shared between the two operating systems on your 1 computer. Or if you have an external drive that goes between Windows and Linux boxen.

As far as security goes…Eh. SMB is one of the ways a pen tested will scrape login tokens for the various machines on your network. SMB/Samba are definitely worth learning, because most companies consider this functionality to be a necessary evil, or just necessary as most companies don’t know how evil it is. However, if you’re big on security yourself, you might check out the various sshfs for Windows projects floating around the internet. Not really important to businesses, but it would be a gold star to you for security.

1 Like

I suppose they could just be exFat correct?

I don’t have experience with pure file servers, what should I look into?

I am using these two computers because the file hosting computer (linux) has to run certain cron jobs on the files.

Is using iptables a step in the right direction?

Mind you, I’m not saying you have to have a specific file system. You can use whatever you like. I just want to clear up a potential misconception that I’ve seen numerous times over the years.

Misconception:
If I’m setting up a Samba server on a Linux box, the file system that holds the files to be shared needs to be NTFS, because that’s what the Windows client knows.

What’s actually going on:
The Samba service is used to pass files back and forth between client (Windows 10) and server (Linux). Samba hands these reads and writes off to Linux, and Linux takes them over. So your only concern, as far as file systems go, is what Linux can and cannot read/write from/to.

To that end, it ends up being a little silly to use something like NTFS or exFAT on Linux. You can do it, and it will be successful at doing it. But don’t restrict yourself to those file systems just because your Windows client doesn’t know how to use anything better.

Does that make sense?

And if you’ve got some other reason to keep those file systems as something that can be read by Windows, then that’s what you’ve got to do. This is just a misconception I’ve seen all over the place, and wanted to make sure it wasn’t happening here.

1 Like

You can use UFW as a front end for iptables which may make it easier to configure. But yeah you can use iptables to only allow access from a specific machine. Or set up password logins for samba, or both.

NTFS = horrible
exFAT = oh god why

Because Microsoft was too proud to support ext2. :slight_smile:

that’s actually exactly had I thought originally. I just don’t know a whole lot about file systems. I’d have to read on advantages and disadvantages.

The main difference between a lot of good filesystems and the bad ones is how they handle superblock, metadata, power outs, and journaling.

NTFS is garbage for data integrity, it basically solely relies on the drive not to have bad blocks, so once it starts to go its like a depressed housewife drowning her misery in alcohol.

exFAT is still fat. Fragmentation out the ass. No redundency, journaling, or metadata. Like cavemen writing data on walls.

HFS/HFS+ is apple’s little baby. Basically like EXT.

EXT is what ships on most distros out of the box. Not bad, decent journaling, but issues when you’re writing data and the power cuts out. Other than that is handles everything much better than NTFS and doesn’t really suffer any kind of fragmentation issues until your drive is >=90% full.

XFS is great for if you deal with large single files. I like to format flash drives with XFS for when I need to transfer large gzip’ed tarballs. Always make sure you don’t cut the power out on this one though because it really shits the bed.

JFS is IBM’s filesystem of choice for AIX. Similar to XFS.

BTRFS is still in development but really good for data integrity, at least in specific raid configurations. Its still baking but is shipped as the default fs for / on Open SUSE. Open SUSE is putting all their eggs in btrfs basket.

ZFS is the de facto filesystem on enterprise servers, SAN’s, and the BSD operating systems. This thing is a complete beast and a joy to work with for fileservers. If you need to maintain absolute data integrity, ZFS is the way to go; and yes its available on linux.

1 Like

And replaced in March of this year by APFS. And boy howdy, was that needed. HFS+ was a workhorse, but I’m amazed that Apple was still able to use it in 2017 at all. Max volume size of 2TB, max file size of 2GB? Hell in 2015 Seagate came out with their 10TB drive. Not that you’d commonly see this in a desktop, but 2-4TB drives were pretty damn common by that point.
fatguy

And 2GB max file size? I was running into trouble with 2GB max file sizes in the early 2000s. How did they manage an additional 17 years?

Another fucking FS.

That’s like the worst parts of FAT32.
What the actual shit.

“It just works is pile of shit”

1 Like