nhanle

Bài: CentOS 8 - Thiết Lập Samba Chia Sẻ Dữ Liệu - Phần II

Jul 10th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. Bài: CentOS 8 - Thiết Lập Samba Chia Sẻ Dữ Liệu - Phần II
  2.  
  3. Mục tiêu
  4. + Thiết lập chia sẻ dữ liệu không bảo mật
  5. + Thiết lập chia sẻ dữ liệu phân quyền
  6.  
  7. 1. Thiết lập chia sẻ dữ liệu Full Quyền
  8.  
  9. [root@samba ~]# dnf -y install samba
  10. [root@samba ~]# mkdir /data-share
  11. [root@samba ~]# chmod 777 /data-share
  12.  
  13. [root@localhost ~]# vi /etc/samba/smb.conf
  14. [global]
  15. unix charset = UTF-8
  16. workgroup = WORKGROUP
  17. security = user
  18. hosts allow = 192.168.1. 172.16.
  19. passdb backend = tdbsam
  20.  
  21. printing = cups
  22. printcap name = cups
  23. load printers = yes
  24. cups options = raw
  25. map to guest = Bad User
  26.  
  27. [Share]
  28. #xac dinh thu muc chia se
  29. path = /data-share
  30. # cho phep ghi du lieu
  31. writable = yes
  32. #Cho phep tat ca tai khoan truy cap vao (nobody)
  33. guest ok = yes
  34. # File tao ra co quyen 777
  35. force create mode = 777
  36. # Thu muc tao ra quyen 777
  37. force directory mode = 777
  38. #File va thu muc tao ra se co user owner va group owner
  39. force user = localuser
  40. force group = localuser
  41.  
  42.  
  43. 2. Thiết lập chia sẻ dữ liệu phân quyền
  44.  
  45. - 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
  46.  
  47. [root@centos1 share]# vi /etc/fstab
  48. => kích hoạt tính năng ACL ở trên phân vùng
  49.  
  50. [root@server ~]# mount -o remount /
  51.  
  52. - Tạo ra folder "/data/share" và sử dụng ACL để phân quyền
  53.  
  54. [root@centos1 share]# mkdir /share
  55. [root@centos1 share]# groupadd student
  56. [root@centos1 share]# groupadd teacher
  57.  
  58. [root@centos1 share]# useradd -g student user1
  59. [root@centos1 share]# useradd -g student user2
  60. [root@centos1 share]# useradd -g teacher gv1
  61. [root@centos1 share]# useradd -g teacher gv2
  62.  
  63.  
  64. [root@vmware data]# cd /
  65. [root@vmware share]# chmod 750 /share
  66. => như vậy OTHER sẽ không có quyền trên folder share
  67.  
  68. [root@vmware data]# setfacl -m g:student:r-x /share
  69. [root@vmware data]# setfacl -m g:teacher:rwx /share
  70. => sử dụng ACL để phân quyền cho từng loại group khác nhau
  71.  
  72. [root@vmware data]# getfacl share/
  73. # file: share/
  74. # owner: root
  75. # group: root
  76. user::rwx
  77. group::r-x
  78. group:student:rwx
  79. group:teacher:rwx
  80. mask::rwx
  81. other::r-x
  82.  
  83. [root@localhost ~]# smbpasswd -a gv1
  84. New SMB password: 123456
  85. Retype new SMB password: 123456
  86. Added user gv1.
  87.  
  88. [root@localhost ~]# smbpasswd -a gv2
  89. New SMB password: 654321
  90. Retype new SMB password: 654321
  91. Added user gv2.
  92.  
  93. [root@localhost ~]# smbpasswd -a user1
  94. New SMB password: 123456
  95. Retype new SMB password: 123456
  96. Added user user1.
  97.  
  98. [root@localhost ~]# smbpasswd -a user2
  99. New SMB password: 654321
  100. Retype new SMB password: 654321
  101. Added user user2.
  102.  
  103. [root@samba ~]# vi /etc/samba/smb.conf
  104. [global]
  105. unix charset = UTF-8
  106. workgroup = WORKGROUP
  107. security = user
  108. hosts allow = 192.168.1. 172.16.
  109. passdb backend = tdbsam
  110.  
  111. printing = cups
  112. printcap name = cups
  113. load printers = yes
  114. cups options = raw
  115.  
  116. map to guest = Bad User
  117. #guest account = localuser
  118.  
  119. [Share]
  120. #xac dinh thu muc chia se
  121. path = /shared
  122. # cho phep ghi du lieu
  123. writable = yes
  124. #Cho phep tat ca tai khoan truy cap vao (nobody)
  125. guest ok = yes
  126. # File tao ra co quyen 777
  127. force create mode = 777
  128. # Thu muc tao ra quyen 777
  129. force directory mode = 777
  130. #File va thu muc tao ra se co user owner va group owner
  131. force user = localuser
  132. force group = localuser
  133.  
  134. [Data]
  135. #xac dinh thu muc chia se
  136. path = /share
  137. #Cho phep ghi du lieu
  138. writable = yes
  139. #Khong cho phep tat ca tai khoan truy cap vao (nobody)
  140. guest ok = no
  141. #valid users xac dinh group nao duoc ket noi vao share
  142. valid users = @teacher @student
  143. #set permission [777] when file created
  144. force create mode = 777
  145. # set permission [777] when folder created
  146. force directory mode = 777
  147. # inherit permissions from parent folder
  148. # inherit permissions = yes
Add Comment
Please, Sign In to add comment