Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bài: CentOS 8 - Thiết Lập Samba Chia Sẻ Dữ Liệu - Phần II
- Mục tiêu
- + Thiết lập chia sẻ dữ liệu không bảo mật
- + Thiết lập chia sẻ dữ liệu phân quyền
- 1. Thiết lập chia sẻ dữ liệu Full Quyền
- [root@samba ~]# dnf -y install samba
- [root@samba ~]# mkdir /data-share
- [root@samba ~]# chmod 777 /data-share
- [root@localhost ~]# vi /etc/samba/smb.conf
- [global]
- unix charset = UTF-8
- workgroup = WORKGROUP
- security = user
- hosts allow = 192.168.1. 172.16.
- passdb backend = tdbsam
- printing = cups
- printcap name = cups
- load printers = yes
- cups options = raw
- map to guest = Bad User
- [Share]
- #xac dinh thu muc chia se
- path = /data-share
- # cho phep ghi du lieu
- writable = yes
- #Cho phep tat ca tai khoan truy cap vao (nobody)
- guest ok = yes
- # File tao ra co quyen 777
- force create mode = 777
- # Thu muc tao ra quyen 777
- force directory mode = 777
- #File va thu muc tao ra se co user owner va group owner
- force user = localuser
- force group = localuser
- 2. Thiết lập chia sẻ dữ liệu phân quyền
- - Kích hoạt tính năng ACL cho partition nếu đang dùng dạng format là ext4. Nếu máy chủ đang dùng dạng format là xfs thì tính năng ACL mặc định được kích hoạt
- [root@centos1 share]# vi /etc/fstab
- => kích hoạt tính năng ACL ở trên phân vùng
- [root@server ~]# mount -o remount /
- - Tạo ra folder "/data/share" và sử dụng ACL để phân quyền
- [root@centos1 share]# mkdir /share
- [root@centos1 share]# groupadd student
- [root@centos1 share]# groupadd teacher
- [root@centos1 share]# useradd -g student user1
- [root@centos1 share]# useradd -g student user2
- [root@centos1 share]# useradd -g teacher gv1
- [root@centos1 share]# useradd -g teacher gv2
- [root@vmware data]# cd /
- [root@vmware share]# chmod 750 /share
- => như vậy OTHER sẽ không có quyền trên folder share
- [root@vmware data]# setfacl -m g:student:r-x /share
- [root@vmware data]# setfacl -m g:teacher:rwx /share
- => sử dụng ACL để phân quyền cho từng loại group khác nhau
- [root@vmware data]# getfacl share/
- # file: share/
- # owner: root
- # group: root
- user::rwx
- group::r-x
- group:student:rwx
- group:teacher:rwx
- mask::rwx
- other::r-x
- [root@localhost ~]# smbpasswd -a gv1
- New SMB password: 123456
- Retype new SMB password: 123456
- Added user gv1.
- [root@localhost ~]# smbpasswd -a gv2
- New SMB password: 654321
- Retype new SMB password: 654321
- Added user gv2.
- [root@localhost ~]# smbpasswd -a user1
- New SMB password: 123456
- Retype new SMB password: 123456
- Added user user1.
- [root@localhost ~]# smbpasswd -a user2
- New SMB password: 654321
- Retype new SMB password: 654321
- Added user user2.
- [root@samba ~]# vi /etc/samba/smb.conf
- [global]
- unix charset = UTF-8
- workgroup = WORKGROUP
- security = user
- hosts allow = 192.168.1. 172.16.
- passdb backend = tdbsam
- printing = cups
- printcap name = cups
- load printers = yes
- cups options = raw
- map to guest = Bad User
- #guest account = localuser
- [Share]
- #xac dinh thu muc chia se
- path = /shared
- # cho phep ghi du lieu
- writable = yes
- #Cho phep tat ca tai khoan truy cap vao (nobody)
- guest ok = yes
- # File tao ra co quyen 777
- force create mode = 777
- # Thu muc tao ra quyen 777
- force directory mode = 777
- #File va thu muc tao ra se co user owner va group owner
- force user = localuser
- force group = localuser
- [Data]
- #xac dinh thu muc chia se
- path = /share
- #Cho phep ghi du lieu
- writable = yes
- #Khong cho phep tat ca tai khoan truy cap vao (nobody)
- guest ok = no
- #valid users xac dinh group nao duoc ket noi vao share
- valid users = @teacher @student
- #set permission [777] when file created
- force create mode = 777
- # set permission [777] when folder created
- force directory mode = 777
- # inherit permissions from parent folder
- # inherit permissions = yes
Add Comment
Please, Sign In to add comment