🔐How To Install File Sharing With Samba Server

Introduction

Samba is software that uses the SMB protocol. Samba is an application that functions to share resources (such as data, printers) between computers connected to a network. So far, Samba is better known for exchanging data between devices using the Windows operating system, but the Samba server can also be used on Unix and Linux based operating systems. Samba servers are widely used because they are easy to configure and use.

Advantages

  1. Samba allows us to share files and directories between different computers on a network. This allows Windows operating system users to access files stored on a Samba (Linux) server as if they were on a Windows computer.

  2. We can use Samba to share printers with other computers on the network, including computers with the Windows operating system.

  3. Samba supports user authentication, which means we can set access permissions to shared files and printers based on users or user groups.

  4. Samba can function well in existing Windows network environments.

  5. Apart from functioning as a file sharing server, Samba can also function as a domain controller, which allows setting and managing user domains on the network.


Configuration

Debian11- Server

Full Access

This Samba setting is for sharing folders in full, which means anyone can access the shared folder without having to log in and can modify (add, change, delete) the contents of the folder

Install Package

apt install samba

Create Directory

mkdir -p /home/public/share

Give Full Access

chmod 777 /home/public/share

Copy File

We will copy the file as a backup which will be useful when we go too far wrong. we just copy the smb.conf.backup file to the default samba file name.

cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

Configuration File

nano /etc/samba/smb.conf

#Full Access
[Share-Public Access]
    path = /home/public/share
    writable = yes
    guest ok = yes
    guest only = yes
    force create mode = 777
    force directory = 777

Restart Service

systemctl restart smbd
systemctl status smbd

Limit Access

In this second configuration, we will create limited access to the shared folder, this restriction is login authentication which must be filled in by the user before accessing the Samba Folder. The author uses access limits based on groups.

UserGroupPath

rizwan-tjkt

tjkt

/home/share/tjkt

rizwan-pplg

pplg

/home/share/pplg

rizwan-mplb

mplb

/home/share/mplb

Add Group & User

groupadd tjkt
groupadd pplg
groupadd mplb

Change Permissions

usermod -aG tjkt rizwan-tjkt
usermod -aG pplg rizwan-pplg
usermod -aG mplb rizwan-mplb

Change Samba Password

smbpasswd -a rizwan-tjkt
smbpasswd -a rizwan-pplg
smbpasswd -a rizwan-mplb

Create Directory

mkdir -p /home/share/tjkt
mkdir -p /home/share/pplg
mkdir -p /home/share/mplb

Group Verification

chgrp tjkt /home/share/tjkt
chgrp pplg /home/share/pplg
chgrp mplb /home/share/mplb

Change Permission Directory

chmod 770 /home/share/tjkt
chmod 770 /home/share/pplg
chmod 770 /home/share/mplb

Samba File Configuration

nano /etc/samba/smb.conf

#Group tjkt
[Share-Group tjkt]
    path = /home/share/tjkt
    writable = yes
    guest ok = no
    valid users = @tjkt
    force gruop = tjkt
    force create mode = 770
    force directory = 770
    inherit permissions = yes

Restart Samba

systemctl restart smbd
systemctl status smbd

Last updated