Linux - Samba Setup No Authentication

Security warning: older versions of this page shared / (the whole file system) writable to guests with force user = root. That gives anyone who can reach the server full root write access to every file on it, with no password. Samba's smb.conf manual notes that whatever privileges the guest account has are available to any client connecting to a guest share, and force user = root makes that account root. A guest-only setup like this is only for an isolated lab network and must never be exposed to an untrusted network or the internet. The [httpd] and [html] shares below also let guests write to the web server configuration and content. This page now shares a dedicated folder as the unprivileged guest account instead.

Step 1: Install Samba on Linux

To get started out with Samba, install the Samba core packages including the client package:

dnf install -y samba samba-common samba-client 

The command installs the packages specified along with the dependencies as displayed on the output. After the installation is complete, you will get a summary of all the packages that have been installed.

Samba Installation Completes

Step 2: Create and Configure Samba Shares

Once all the samba packages have been installed, the next step is to configure the samba shares. A samba share is simply a directory that is going to be shared across client systems in the network.

Next, we are going to make some configurations in the smb.conf configuration file which is Samba’s main configuration file. But before we do so, we will back up the file by renaming it with a different file extension.

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

Next, we are going to create a new configuration file.

vim /etc/samba/smb.conf

This will define the samba share by adding the lines shown in the configuration file.

[global]
unix charset = UTF-8
hosts allow = 192.168.x.
map to guest = Bad User
log file = /var/log/samba/log.%m
log level = 1
server role = standalone server

[httpd]
path =  /etc/httpd/
read only = no
guest ok = yes
guest only = yes
force user = apache
force group = apache

[html]
path =  /var/www/html/
read only = no
guest ok = yes
guest only = yes
force user = apache
force group = apache

[public]
# Guest-only share: no password, guests run as the guest account (default: nobody)
path =  /srv/samba/public
read only = no
guest ok = yes
guest only = yes

Save and exit the configuration file.

Create the dedicated public folder, make it owned by the guest account (nobody) so guests can write to it, and give it the Samba SELinux label:

mkdir -p /srv/samba/public
chown -R nobody:nobody /srv/samba/public
chmod 0755 /srv/samba/public
semanage fcontext -a -t samba_share_t "/srv/samba/public(/.*)?"
restorecon -Rv /srv/samba/public

There is no force user line on this share: with guest only = yes every connection already runs as the guest account (default nobody), so guests can only write where nobody can. Never set force user = root on a guest share. If semanage is missing, install policycoreutils-python-utils.

To verify the configurations made, run the command:

testparm

This verifies Samba Configuration

Next, start and enable Samba daemons as shown.

systemctl enable --now smb;systemctl enable --now nmb

Be sure to confirm that both the smb and nmb daemons are running.

systemctl status smb;systemctl status nmb

This verified Samba Status

Step 3: Accessing Samba Share from Windows

Thus far, we have installed samba and configured our samba share. We are now ready to access it remotely. To do this on a Windows client, press the Windows logo key + R to launch the Run dialog.

In the textfield provided, enter the samba server’s IP address as shown:

\\server-ip

This accesses Samba Share from Windows

Some data from here

https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server

 

Sources


Revision #2
Created 1 February 2025 04:41:41 by Admin
Updated 24 October 2026 14:10:46 by Admin