Setting Up Samba on Raspberry Pi for File Sharing

Introduction

Today, I will discuss how to set up Samba on Raspberry Pi for file sharing.

Installation

sudo pacman -S samba

The configuration file is located at /etc/samba/smb.conf, but when you check this path, you will find it is empty.

After searching for a while, I finally found a solution in Using Samba on Manjaro for Cross-System File Sharing in Local Area Network – JianShu[1]. You need to install manjaro=settings-samba

sudo pacman -S manjaro-settings-samba

Once installed, it will be available.

Add User

sudo smbpasswd -a xxx # Create a user

Note that if the user does not exist on your computer, you cannot add them successfully. For example, if you use test, it will report the following error.

sudo smbpasswd -a test
New SMB password:
Retype new SMB password:
Failed to add entry for user test.

If you are not sure which users exist on the system, you can check with the following command:

cat /etc/passwd

Add New User

If you want to add a new user, you can create a new group and then add the new user.

sudo groupadd test1 -g 6000 # Create test1 user group
sudo useradd test1 -u 6000 -g 6000 -s /sbin/nologin -d /dev/null # Add test1 to the test1 user group and set it to not allow login

At this point, you can use smbpasswd -a test1 to successfully add the user.

Configuration

Create a share folder under home for file sharing.

Open /etc/samba/smb.conf and add the following content at the end. Modify the path according to your situation.

[shared]
    comment = Samba Shared
    path = /home/test/share
    public = no
    valid users = test
    browseable = yes
    writable = yes
    create mask = 0777
    directory mask = 0777

Connection

Once configured, you can start connecting.

For example, on a Mac, open Finder and use the shortcut cmd k to open the Connect to Server interface.

In the input box, enter smb://ip, then select Connect, and enter the username and password to see the directory configured in Samba.

Setting Up Samba on Raspberry Pi for File Sharing

Conclusion

Samba can be quite complex with many configurations, but it is necessary for certain tasks, such as camera backups.

References
[1]

Using Samba on Manjaro for Cross-System File Sharing in Local Area Network – JianShu:https://www.jianshu.com/p/b0fcf29a857a

[2]

dperson/samba: Samba docker container:https://github.com/dperson/samba

[3]

Using Samba on Manjaro for Cross-System File Sharing in Local Area Network – JianShu:https://www.jianshu.com/p/b0fcf29a857a

[4]

[Problem Solving] Failed to add entry for user when adding user and password in Samba – CSDN Blog:https://blog.csdn.net/p1279030826/article/details/111409106

Setting Up Samba on Raspberry Pi for File Sharing

Previous Recommendations

Pengpai OS2 and Mac Interconnection

Compressing Git Repository

DeepL Free Translation Version

Setting Up Samba on Raspberry Pi for File Sharing

Leave a Comment

×