Configurar samba smb en entronos RedHat / centos version 7.X 8.X ... 2020

 

What is Samba

To provide printer and file sharing, Microsoft Windows uses a facility known as SMB (Server Message Block). This same facility is sometimes known as NetBIOS or LanManager. Thanks to Andrew Tridgell and others, Linux systems provide support for SMB via a package known as Samba. Like SMB, Samba lets you:

  • Share printers and files among Microsoft Windows, OS/2, Netware, and Unix systems
  • Establish a simple nameserver for identifying systems on your local area network
  • Backup PC files to a Linux system and restore them
  • Administer users and passwords

Samba has proven its reliability and high performance in many organizations.Samba software suite on Enterprise Linux is a collection of programs that implements the Server Message Block (commonly abbreviated as SMB) protocol for UNIX systems.

Installing Samba

In Enterprise Linux system, install below packages to get started with Samba. You can download/install these packages from yum server using the “yum install” command.

samba       #### basic Samba packages
samba-client       #### samba client

To install these packages :

# yum install samba
# yum install samba-client

If you are using an active directory setup, install below packages as well.

# yum install samba-winbind
# yum install samba-winbind-clients
# yum install samba-winbind-krb5-locator

Below are the list of packages which will be installed once you have installed the above packages.

samba-libs
samba-winbind-krb5-locator
samba-winbind-modules
samba-vfs-glusterfs
samba-winbind
samba-client
samba-common
samba-winbind-clients
samba

Configuring a Samba share

Samba’s configuration usually resides in /etc/samba/smb.conf which contains all the configuration parameters related to samba. Follow the steps given below to configure a samba share.

1. For the share to be accessible to a particular user, we must first create a user (john) on the linux server where the share resides as well.

# useradd john
# passwd john
Changing password for user john.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

2. To add activate the Samba user and set the password, use the “smbpasswd” command with the -a option.

# smbpasswd -a john

3. Create the directory to share or you can use an existing directory. Also set full permissions on the directory.

# mkdir -p  /path/to/share
# chmod -R 777 /path/to/share

4. Next, set the SElinux contexts on the share. Verify if you can create a file in the share.

# chcon -R -t samba_share_t /path/to/share
# cd /path/to/share
# echo test > testfile.txt

5. Edit the /etc/samba/smb.conf file and add the share settings.

# vi /etc/samba/smb.conf
[share_name]
    path = /path/to/share
    comment = samba share for john
    public = yes
    writable = yes
    create mask = 0777
    browseable = yes

Restart samba service for the above settings to take effect.

# service smb restart

To enable the service so that it survives a reboot execute the following:

systemctl enable smb


Troubleshooting

To find out the issue with a samba share, you can try disabling the iptables service and turning off the SELinux. Make sure to enable them back after you resolve the confilct.

# service iptables stop
# setenforce 0

Verify samba parameter using testparm
To verify that the parameters are correct in the smb.conf file or to debug configuration problems, use the testparm command.

logs
For debugging problems with Samba in general, the log files log.smbd and log.nmbd under the /var/log/samba directory are invaluable. The parameter log level in the global section of the smb.conf file determines the amount of detailed information Samba writes to the log files, with level 0 being the most general and 10 being the most detailed. Each logging level contains the messages from that level, in addition to the logging messages below it. For example, a logging level of 5 contains messages from level 5, plus those from levels 0 through 4.

# vi /etc/samba/smb.conf
# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log
debuglevel = 4

Comentarios

Entradas populares de este blog

Orange Pi IoT 2G Flashear memoria NAND

Usar datos gratis para proyectos IoT FreedomPop y Orange Pi 2G IoT (también Simyo).

Configurar modem GSM en la Orange Pi 2G IoT (Orange España)