Frequently Asked Question

Samba (SMB) Server on Linux
Last Updated 11 months ago

Samba (SMB) Server on Linux

How to Install Samba Server on Debian/RHEL and Configure Users

Prerequisites:

  • A Debian or RHEL server.
  • Administrative privileges.

For Debian (e.g., Ubuntu):

   sudo apt update
  1. Update the package list:
   sudo apt install samba
  1. Install Samba:

For Red Hat Enterprise Linux (RHEL) or CentOS:

   sudo yum install -y samba
   sudo systemctl enable smb
   sudo systemctl start smb
  1. Enable and start the Samba service:
   sudo yum install -y samba-common-tools
  1. Install additional packages for security and management:

Step 2: Configure Samba

Editing /etc/samba/smb.conf

   sudo nano /etc/samba/smb.conf
  1. Open the configuration file:
  1. Add or modify the following sections:

Global settings:

   [global]
   workgroup = WORKGROUP
   server string = Samba Server %v
   netbios name = YOURSERVERNAME
   security = user
   map to guest = bad user

Shared directory (e.g., /srv/smbshare):

   [smbshare]
   path = /srv/smbshare
   valid users = johndoe jane_doe
   read only = no
   browsable = yes
   guest ok = no
  1. Save and exit the file.

Step 3: Add Users to Samba

   sudo useradd -M johndoe -s /sbin/nologin
  1. Create a new user (e.g., johndoe):
   sudo smbpasswd -a johndoe
  1. Set a password for the user:
  1. Repeat steps 1 and 2 for other users (jane_doe in this example).

Step 4: Testing with smbclient

To test the Samba share, you can use the smbclient tool.

Test from a Windows machine:

smbclient \\\\<SERVER_IP>\smbshare -U johndoe%password

Test from Linux (using smbclient):

smbclient //<SERVER_IP>/smbshare -U johndoe%password -c "ls"

This command lists the contents of the shared directory, confirming that Samba is working correctly.

Conclusion

You have successfully installed and configured a Samba server on your Debian or RHEL machine. Testing with smbclient ensures that users can access the shared directory as intended.

This FAQ was generated and/or edited by GAIN, GENs Artificial Intillegence Network and should not be considered 100% accurate. Always check facts and do your research, things change all the time. If you are unsure about any information provided, please raise a support ticket for clarification.
Powered by GEN UK CLEAN GREEN ENERGY

Loading ...