# Linux - Samba Setup No Authentication

<p class="callout warning">**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.</p>

### Step 1: Install Samba on Linux

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

```bash
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

<div data-layout="center" data-node-type="mediaSingle" data-width="250" data-width-type="pixel" id="bkmrk--2"></div>### 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.

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

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

```bash
vim /etc/samba/smb.conf
```

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

```bash
[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:

```bash
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:

```bash
testparm
```

This verifies Samba Configuration

<div data-layout="center" data-node-type="mediaSingle" data-width="250" data-width-type="pixel" id="bkmrk--5"></div>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

<div data-layout="center" data-node-type="mediaSingle" data-width="250" data-width-type="pixel" id="bkmrk--7"></div>### 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 <span class="code" spellcheck="false">key + R</span> 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](https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server)

<div data-layout="center" data-node-type="mediaSingle" data-width="250" data-width-type="pixel" id="bkmrk--9"></div>#### Sources

- [https://wiki.samba.org/index.php/Setting\_up\_Samba\_as\_a\_Standalone\_Server](https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server)
- [https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html](https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html)
- [https://docs.redhat.com/en/documentation/red\_hat\_enterprise\_linux/9/html/configuring\_and\_using\_network\_file\_services/assembly\_using-samba-as-a-server\_configuring-and-using-network-file-services](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_and_using_network_file_services/assembly_using-samba-as-a-server_configuring-and-using-network-file-services)