PI Ubuntu: Sharing folder on network using Samba to Windows 10 client

Ok, so in my last post I had just set up my centralised remote syslog server on my raspberry PI and everything was going well. Now I thought to myself, do I really want to be SSHing into the box every time I want to check a log. No not really. So I contemplated this issue for a while and decided that a network shared folder would be the way to go. I could access it directly from my main windows system and I could map it to a network drive. Excellent, what could go wrong.

So I embarked on my journey to setup the Samba network share, lots of guides online, looking promising.

Looking at the guides they were mainly about mounting a network drive. I quickly realised this was the reverse of what I was searching for. Mounting a network drive shared by a windows or other OS for use within the Linux system. It pains me, I’m normally aching good at finding what I want in Google.

Anyway I followed a few posts:

That got me close but not close enough. What ever I did I got an permissions error in windows 10. I could see the computer in the network view, I just couldn’t access it. The following error was presented each time from the Run command:

The run command to access your shared folder and get something similar to the bellow error
“You can’t access this shared folder because your organisation’s security policies block unauthenticated guest access. These policies help protect your PC from unsafe or malicious devices on your network

The other option using the Network panel and selecting the computer just provides a pain and simple can’t connect, would you like to diagnose box? Which if followed is about as helpful as a chocolate tea pot. It had nothing to do with my firewall and open or closed ports as many post suggestions might have you believe.

A little more searching and I thought I had what I needed. Alas no, I went through 4 or 5 guides before stumbling across the comments on another guide. Thank you to the guide maker for the page and mainly to “Bad Bad Pants, September 19, 2017” within the comments section.

https://www.cyberciti.biz/faq/how-to-configure-samba-to-use-smbv2-and-disable-smbv1-on-linux-or-unix/

In short, Windows 10 will not interact with a Samba server running SMB1 protocol, or at least not without turning off various security profile elements to allow guest access authentication. You probably don’t want to do this.

Of course I don’t need to explain why turning off security options is a whole lot of nasty waiting to happen. So, without further adieu, this is my setup for samba file sharing.

Samba setup

Here is what I did to get it running with Win 10. Start by installing the required components.

sudo apt-get install samba samba-common-bin 

Excellent, now just edit the example config file… good practise would say back this up for reference:

sudo mv /etc/samba/smb.conf /etc/sambe/smb.conf.bak

Then delete / comment everything out leaving something like the following:

[global]
    workgroup = WORKGROUP
    security = user
    server min protocol = SMB2_10
    client min protocol = SMB2
    client max protocol = SMB3
    min protocol = SMB3
    server string = %h server (Samba, Ubuntu)
    wins support = yes
    log file = /var/log/samba/log.%m
    max log size = 1000
    panic action = /usr/share/samba/panic-action %d
    server role = standalone server
    passdb backend = tdbsam
[RemoteSysLogs]
    path = /var/log/remote
    valid users = @smbgroup
    guest ok = no
    writable = yes
    browsable = yes

At this point I had to ensure I had a user on the system I wanted to give access to the service.

sudo useradd <username>
sudo passwd <password>

Create a group for the share. Note that in my samba config I have used @smbgroup which we will create if it does not exist

 sudo groupadd smbgroup

Then add the user to the samba share group

 sudo usermod -a -G smbgroup <username> 
sudo smbpasswd -a <username>
sudo smbpasswd -e <password>

You can now change the permissions on your share folder to include your samba group. Create the directory if you have not already done so.

sudo chgrp smbshare /var/log/remote 
​sudo chmod -R 770 /var/log/remote

By changing the group permissions you can manage read and write access to the directory and sub directories.

Finally restart the service

sudo service smbd restart

You should now be able to access your shared folder from a Windows 10 machine. On connecting the server should prompt for a username and password which will be the user and pass we setup during this process.

Leave a Reply

Your email address will not be published. Required fields are marked *