Samba configuration of different users access to different user groups

 

1, first of all by way of user authentication server, each user can access their home directory, and only the user can access the home directory, and have full rights, while others can not see your home directory.

2, the establishment of a caiwu folder, and hope people caiwu group lingdao group can see, network02 can access, but only caiwu01 has write permissions.
3, the establishment of a lindao directory, only the leadership of the group of people can access and read and write, as well as network02 can access, but outsiders can not see that directory
4, establish a file exchange directory exchange, everyone can read and write, including guest users, but everyone can not delete other people's files.
5, the establishment of a public read-only folder public, all of this read-only folder.
Well, let's work early
The establishment of three groups:
#groupadd caiwu
#groupadd network
#groupadd lingdao
Add users and join related groups which:
#useradd caiwu01 -g caiwu
#useradd caiwu02 -g caiwu
#useradd network01 -g network
#useradd network02 -g network
#useradd lingdao01 -g lingdao
#useradd lingdao02 -g lingdao
Then we use the command smbpasswd -a caiwu01 six accounts were added to the samba users
#mkdir /home/samba
#mkdir /home/samba/caiwu
#mkdir / home / samba / lingdao
#mkdir /home/samba/exchange
#mkdir /home/samba/public
We permission in order to avoid trouble where you can put all the files in the folder are set to above 777, we set five points above requirements by samba flexible rights management.
The following is my smb.conf configuration file
[global]
workgroup = bmit
# My Network Working Group
server string = Frank's Samba File Server
# Describe my server name
security = user
# Use user authentication mechanism
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
# Use password encryption mechanism used in win95 and winnt is expressly
Other basically by default to.
[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
create mode = 0664
directory mode = 0775
#homes paragraph satisfies Condition 1
[Caiwu]
comment = caiwu
path = /home/samba/caiwu
public = no
valid users = @ caiwu, @ lingdao, network02
write list = caiwu01
printable = no
#caiwu second segment to meet our requirements
[Lingdao]
comment = lingdao
path = / home / samba / lingdao
public = no
browseable = no
valid users = @lingdao,network02
printable = no
#lingdao segment to meet the requirements of our third
[exchage]
comment = Exchange File Directory
path = /home/samba/exchange
public = yes
writable = yes
#exchange segment can basically meet our 4 requirements, but can not satisfy everyone can not delete this file condition of others, even if set in a mask is useless, in fact, as long as this condition unix set a sticky bit on the line
chmod -R 1777 /home/samba/exchange
Note that permissions are 1777, similar to the system / tmp directory has the same rights, the rights can be realized everyone can freely write files, but you can not delete the others file this request
[public]
comment = Read Only Public
path = /home/samba/public
public = yes
read only = yes
# The public can meet our requirements of paragraph 5.
So far we have been able to achieve our set of requirements to share files, remember to restart the service oh
#/etc/rc.d/init.d/smb restart
If there are no winodws, may wish to use the samba cilent end command to test
Usage command I am here only a few examples, we go to a specific test
smbclient -L server ip -N
guest check your account samba server sharing situation, you can test whether lingdao directory when guest account can be seen, should not be seen, of course, you can also view a user's behalf
smbclient -L server ip -U caiwu01
The system will prompt for password, just enter smb password on the line.
smbclient // server ip / caiwu -U caiwu01
# Caiwu01 in the name of the directory user's login caiwu
smbmount // server ip / caiwu / mnt / caiwu -o username = caiwu01
# The financial directory server mapped to local / mnt / caiwu directory.
test
Password smbclient -L // localhost / share or smbclient-L \\ 127.0.0.1 -Umyname // input time is just set password samba
use
1, windows user
In the My Computer address bar type \\ 192.168.1.1 access; windows + R can also enter \\ 192.168.1.1;
After logging in you can right-mapped to a local drive.
net use * /delete
2、linux
(1) Use smbclient
#smbclient//192.168.1.1/Normal -U user%passwd
(2) mounted to a directory use
#mkdir/mnt/share
#mount -o username=youruser,password=passwd //192.168.1.1/Normal  /mnt/share
Power is provided to the mount command is written as / etc / fstab
//192.168.1.1/share  /mnt/ml45  cifs  defaults,auto,username=youruser,password=passwd 0 0

 

Then #mount -a

 

 Other cases: https://blog.csdn.net/qq_21419995/article/details/80739003

 

Guess you like

Origin www.cnblogs.com/bongem/p/12110111.html