Setup Samba file sharing for CentOS 6

The SAMBA protocol allow Linux hosts to create/mount windows compatible network shared folders. Samba shares are preferred when the LAN comprises of both Widnows and Linux computers. In this tutorial, we’ll create a samba shared folder with username/password authentication. The shared folder will be accessible to all Linux and Windows computer on the local network.

Creating a Samba with authenticated user

Install the samba packages
# yum install samba samba-client

Create a backup of the original samba config and then create a new config.
# mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
# nano /etc/samba/smb.conf

Define the properties of the share on the /etc/samba/smb.conf.
comment = myshare
path = /media/myshare
public = no
force user = kenneth
force group = kenneth
valid users = kenneth
writable = yes
browseable = yes

Create the share folder and set permission to the intended user.
# mkdir -p /media/myshare
# chown username.groupname /media/myshare

Be sure the user exist on the system, if not, create it first using useradd, then setup the smbpasswd for the user
# useradd username
# smbpasswd -a username

Start the smb and nmb services then test the share.
# /etc/init.d/smb start
# /etc/init.d/nmb start
# smbclient -L //localhost/data -U kenneth

Mount the samba share on a linux computer:
# mount –t cifs -o user=username,pass=password '//serverIP/ShareName' /mount/point

# mount –t cifs -o user=administrator,pass=pass123 '//' /media/myshare

If you have a Windows machine on the same network, you should be able to access the samba shared folder on “My Network Places.

– masterkenneth

Leave a Reply

Your email address will not be published. Required fields are marked *