Configuring Samba on CentOS

1 .Installing samba via yum

yum -y install samba samba-common samba-client

Configuring samba. Before changing the configure file, back up the original file:

cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

1.1 Examples on setting password protected Samba share

vi /etc/samba/smb.conf


[global]
workgroup = WORKGROUP
server string = ncu12345678
security = User 
load printers = yes
cups options = raw
[share]
writeable = yes
path = /home/ajohn/dataswitch/windows
#do not use this setting since it will cause all created files owned by root
#admin users = user
force user = ajohn
valid users = ajohn
public = yes
available = yes
guest ok = no
# I changes the permissions to rw-rw-r--
create mask = 664
force create mode = 664
security mask = 664
force security mode = 664

directory mask = 0775
force directory mode = 0775
directory security mask = 0775
force directory security mode = 0775


Save and exit the configuration file.



2. Create Samba User

After you have install samba sever, yous still can’t login samba server. You will need create a samba user :
smbpasswd -a username
‘-a’ switch tell smbpasswd we want to add a new user, username is the user you want to add.

Please take note, username must exist in /etc/passwd file or you will need use ‘useradd’ to create a user in Linux :

sudo /usr/sbin/useradd -d /home/username -s /bin/false -n username
 
This will create a new user with same group name with (told by ‘-n’), but the user can’t login and run any shell command (because you have specfic the login shell is /bin/false by the ‘-s’ switch, if you want allow user to able to login to a shell, replace /bin/false with /bin/sh).

Ok now you have create a new samba user, how about you want delete or disable them? ‘-d’ switch will disable the user to login to samba server:
smbpasswd -d username
If you want to delete a user permanently:
smbpasswd -x username
3. Start the Samba service

sudo /etc/init.d/smb start

Question: If you encounter "access denied error"? check whether you have set SeLinux to disabled or permissive

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...