avatar
ねぉじゅりえと
ねぉじゅりえと是NeoJuliet的谐音

Statistics

  • Total Posts: 7
  • Total Tags: 8

Simple Use of Samba

By Juliet
Pubilshed on

By Juliet

Introduction of SMB&Samba

SMB(Server Message Block) is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the SMB/CIFS protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.

Samba is a free software re-implementation of the SMB networking protocol, and was originally developed by Andrew Tridgell. Samba provides file and print services for various Microsoft Windows clients[4] and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member. As of version 4, it supports Active Directory and Microsoft Windows NT domains.

Installation

If you are using pacman as your package manager, run commands below to install

sudo pacman -S samba

Configuration

You can also check Samba in Archwiki for reference Usually, the configure file of samba is /etc/samba/smb.conf But the samba package does not provide this file, you need to create it before starting smb.service A documented example as in smb.conf.default from the Samba git repository may be used to setup /etc/samba/smb.conf

wget "https://git.samba.org/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD" -O smb.conf

Don’t forget to run testparm to check for syntactic errors

Enabling and Staring Services

sudo systemctl enable smb.service
sudo systemctl start smb.service

If you want to make your service accessible via NetBIOS host name, set the desired name in the netbios name option in smb.conf and enable/start nmb.service

Basic Settings

User Management

Only users those who have Linux account are able to access the samba server, you can create a special account or use current accounts

Although the user name is shared with Linux system, samba uses a password seperate from that of the Linux user accounts Use the following command to set the password of a user

smbpasswd -a <smb_user_name>

Use the following command to change the password of a user

smbpasswd <smb_user_name>

Use the following command to list all the samba users

sudo pdbedit -L -v

Create an Anonymous Share

First create a Linux user which anonymous samba user will be mapped to

sudo useradd smb_guest -s /bin/nologin

Note that the username can be any vaild Linux username, and it does not need to be a samba user Then add the following to /etc/samba/smb.conf

...
[global]
security = user
map to guest = bad user
guest account = smb_guest

[guest_share]
    comment = guest share
    path = /<your target path>
    public = yes
    only guest = yes
    writable = yes
    printable = yes

Anonymous users will now be mapped to the Linux user guest and have the ability to access any directories defined in guest_share.path, which is configured to be /<your target path> in the example above. And make sure that the Linux user smb_guest has the proper permissions to access files in guest_share.path

More Details Will Be Updated


Comments

Comment freeeeely

Article License

Simple Use of Samba

Author Juliet Published License: CC BY-SA 4.0