Walker News

How To Configure Samba To Support Shared Folder With And Without Password?

Let’s modify the 3-minute guide for creating Linux shared folder using Samba software, to allow users access public folders without prompting for password but enforce authentication for non-public folders.

NOTE: This guide is tested on Samba version 3.5.10-125 (comes with the RHEL6.3 distribution). So, let’s assume you’ve installed the Samba server package.

For sake of convenient, login as root user to do setup. Firstly, let’s create a Linux user account (e.g. gstusr). Skip this if you would like to use an existing account.
useradd -d /home/gstusr gstusr

Then, create a Samba password for the Linux user account (e.g. gstusr in this guide):
smbpasswd -a gstusr

Next, create two folders for sharing by gstusr:
su - gstusr
mkdir dump
mkdir read

Create public shared folder in /tmp directory:
mkdir /tmp/.smbpub

Backup the original smb.conf file before initialize it:
cd /etc/samba
cp smb.conf smb.conf.ORG
vi smb.conf

While in the vi editing mode, insert this sample configuration into the empty smb.conf file:
  workgroup = Samba01
  server string = Samba01
  netbios name = Samba01
  security = user
  passdb backend = tdbsam
  #--> To enable password-less shared folder:
  map to guest = Bad User

  path = /home/gstusr/dump
  writable = yes

  path = /home/gstusr/read
  writable = no

  path = /tmp/.smbpub
  writable = no
  public = yes
  only guest = yes
What does this sample of smb.conf do?
Essentially, this sample configuration tells Samba to create 3 hidden shared folders:

1. The suffix “$” tells Samba to create hidden shared folder.

2. Requires password authentication to access dump$ (writable) or read$ (read-only) shared folder.

3. Allows everyone to access the read-only public$ shared folder without asking for login / password.

Now, run testparm command to verify the smb.conf configuration file. If there is no error/warning, then let’s start the Samba server:
service smb start

Optionally, if you want to auto start Samba server after Linux boots up:
chkconfig --level 345 smb on

Finally, let’s test the access to Samba01 (IP address is

Access Samba shared folder from another Linux

Assuming you’ve the latest/equivalent version of Samba client installed on this different Linux machine, try this:
smbclient //$ -U gstusr
smbclient //$ -U%

Access Linux shared folder from Windows

This command should open the hidden public shared folder without asking for authentication:
start \\\public$

When it prompts for login, enter the user name as “this\gstusr” and then the corresponding password (that you’ve entered for “smbpasswd -a”):
start \\\read$

Custom Search

2016  •  Privacy Policy