Configure samba server in centos
1. Install yum
yum install samba samba-client samba-commo
2. Set startup
chkconfig smb on chkconfig nmb on
3. Add the following configurations to the firewall:
iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT service iptables save
4. Configure the configuration file vi/etc/samba/smb. conf of samb and add the following content:
[Global] # global configuration workgroup = WORKGROUP # security = share map to guest = bad user [MyShare] path =/home/samba/share browsable = yes writable = yes guest OK = yes read only = no
Create a file directory and set its permissions
mkdir /home/sambamkdir /home/samba/sharechmod -R 0777 /home/samba/share
Check the configuration file and restart the service.
testparm service smb restartservice nmb restart
The above is only public configuration, but user permissions are not set. The following is to set user name permissions to access add user groups.
groupadd users
Add User
useradd gaq
Add User gaq to user group
usermod -a -G users gaq
Set password for samba gaq
Smbpasswd-a gaq # You will be prompted to enter the password
Then we create a directory
mkdir /home/samba/mima
Change directory user group
chgrp users /home/samba/mima
Change permissions
chmod 2755 /home/samba/mima
Modify samba configuration file
vim /etc/samba/smb.conf
Add the following content
[mima]path = /home/samba/mimavalid users = @usersguest ok = nowritable = yesbrowsable = yes
Restart service
service smb restart service nmb restart