1

This has been asked a million times before, and I've looked at a few hundred "solutions" spanning decades, none of which work 100%.

What I want:

A simple, minimal smb.conf that I can package up in an Alpine Linux based LXC container that is discoverable, browsable via WORKGROUP and allows full, unrestricted guest access to /mnt/shared without asking for a password. Something where a family member goes to "Network" on their computer (windows, mac, linux, chromeos), sees "Fileshare", clicks on it, and it just works (read and write access).

What I've tried:

  • messing with tons of settings like security = shared, security = user, map to guest = Bad User, guest account = nobody, force user = nobody, local master = yes, local master = no, various incantations of name resolve order, and a bunch of other things I can't remember at the moment.
  • Changing permissions and ownership to nobody, root, your-mother...
  • Looking through every forum, SO, SU, SF post about this EXACT SAME ISSUE and following the solution marked SOLVED, to no effect.
  • Of course tried https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server
  • booted and rebooted and reinstalled and rebooted again every machine on my network.

Samba configuration is harder to get right than sendmail. Nothing ever seems to work quite right, such that any given config causes one or more of:

  • The server can't be discovered by browsing the network
  • The server can be browsed to manually, but doesn't automatically show up in the windows "Network" section
  • The server can be discovered by some systems but not others (mac, linux, windows)
  • The server can only be accessed via IP address, not by name
  • The client side keeps asking for a password to browse WORKGROUP
  • The client side keeps asking for a password to view the share itself
  • The client keeps complaining about permission problems, even after a chown -R
  • The client side keeps timing out
  • The client side is VERY VERY slow, taking 10-30 seconds for many operations

To make things worse, samba is very temperamental when it comes to environment, such that user accounts, permissions and ownership, and even mismatched network classes can cause it to fail spectacularly with generic error messages that don't help diagnose the problem.

So, what I'd like to know is: Can someone provide a clean smb.conf for a freshly made container that just works, for a full guest access, fully browsable, fully discoverable on all clients, non-slow share of a single directory? For example:

[global]
   map to guest = Bad User
   security = user
   guest account = nobody

[shared]
   path = /mnt/shared
   public = yes
   only guest = yes
   writable = yes
   printable = no
   force user = nobody

(note: The above config doesn't work)

I can adjust the environment to match whatever assumptions you want (though I'd prefer Alpine as a distro because it has less moving parts). I just want a minimal, baseline "guaranteed works" setup which I can then build out from incrementally rather than flailing about like I do every time I have to set up file sharing.

Then I can just make an lxc container template that has a canonical, guaranteed-to-work config and environment, and be done with it forever.

  • Most of the errors you see are all on Windows. If you want something super reliable, don’t use SMB. – Daniel B Apr 18 '18 at 9:14
1

OK, I've managed to put together a config that solves everything, including discoverability under Windows.

The trick for windows discoverability is to have the NetBIOS name match the hostname, and be 15 characters or less.

/etc/samba/smb.conf:

[global]

# Identification
netbios name = same-as-hostnanme
workgroup = WORKGROUP
server string = Samba Server Version %v

# Network
name resolve order = bcast host lmhosts wins

# Protocol
server role = standalone server
disable netbios = no
wins support = yes
dns proxy = yes
domain master = yes
local master = yes
preferred master = yes
os level = 31

# Security
security = user
map to guest = Bad User
guest ok = yes
guest only = yes
guest account = nobody

# Needed by some Windows installs
server signing = auto

# Printing
load printers = No
printing = bsd
printcap name = /dev/null
disable spoolss = Yes

# Files
directory mask = 0755
force create mode = 0644
force directory mode = 0755
case sensitive = True
default case = lower
preserve case = yes
short preserve case = yes

# Performance
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
read raw = yes
write raw = yes
server signing = no
strict locking = no
min receivefile size = 16384
use sendfile = Yes
aio read size = 16384
aio write size = 16384

# Logging
syslog = 0
max log size = 100

/etc/avahi/services/samba.service:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>

  </service>
</service-group>

This avahi config gives lightning fast access and throughput, and makes the service instantly dicoverable to all Bonjour enabled systems (Mac and Linux).

0

I've set up a server with a directory drwxrwxrwx jnl jnl /share/backup. This directory is shared via samba with following smb.conf:

[global]
workgroup = WORKGROUP
log file = /var/log/samba/log.%m
max log size = 1000
server role = standalone server
security = user
map to guest = Bad Password

[Backup]
path = /share/backup
writeable = yes
browsable = yes
guest ok = yes

With this configuration, I'm able to use the share under every other (Windows) OS directly without a user/password and with R/W rights. The files are created with -rw-r----- nobody nogroup FILE and folders with drwxrwxr-x nobody nogroup DIR.

If I want the share to be hidden, just set browsable = no.

  • With this config, it's not discoverable, and browsing is very slow – Karl Apr 18 '18 at 10:46
  • What do you mean by "not discoverable"? Do you have an example where the share is discoverable? What are your network settings? Which permissions does your directory have? – jnL Apr 18 '18 at 11:22
  • I mean that going to "Network" in the file browser in Windows, Mac, or Linux doesn't show the server. Browsing through WORKGROUP doesn't show it either. Everything is on the same 192.168.178.x network, the share directory is owned by nobody and is drwxr-xr-x. Also, attempting to go directly (smb://fileshare/shared) takes 30-45 seconds. – Karl Apr 18 '18 at 11:40
  • The thing is, I KNOW these problems can be overcome somehow, because I've worked in offices where the backend is linux/samba based. I just didn't know what configuration they used to make it all work :/ – Karl Apr 18 '18 at 11:41
  • For making the server/share discoverable for other systems in the same network you can try to use workgroup = WORKGROUP in your [global] or even in your [shared] section (also see here). – jnL Apr 19 '18 at 7:25

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.