Advertisement
echoslider

finish_samba_fileshare

Jul 20th, 2023 (edited)
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.54 KB | None | 0 0
  1. #My Samba Share with Public+Private Share (Ubuntu)
  2.  
  3. su
  4. apt-get install samba acl
  5.  
  6. cat > /etc/samba/smb.conf << SMBCONF
  7.  [global]
  8.  server min protocol = SMB2_02
  9.  server max protocol = SMB3
  10.  server string = fileserver
  11.  workgroup = WORKGROUP
  12.  netbios name = fileserver
  13.  wins support = yes
  14.  local master = yes
  15.  preferred master = yes
  16.  time server = yes
  17.  security = auto
  18.  unix extensions = yes
  19.  name resolve order = lmhosts host wins bcast
  20.  include = /etc/samba/shares.conf
  21. SMBCONF
  22.  
  23.  
  24. cat > /etc/samba/shares.conf << SHARECONF
  25.  [Public]
  26.  path = /storage/share/samba/public_files/
  27.  force group = smbgroup
  28.  create mask = 0750
  29.  force create mode = 0750
  30.  directory mask = 0750
  31.  force directory mode = 0750
  32.  public = yes
  33.  writable = yes
  34.  hide unreadable = Yes
  35.  access based share enum = Yes
  36.  nt acl support = yes
  37.  inherit acls = no
  38. SHARECONF
  39.  
  40.  
  41. useradd -s /bin/false smbadmin
  42. smbpasswd -a smbadmin
  43. groupadd smbgroup
  44.  
  45. useradd -s /bin/false user1
  46. smbpasswd -a user1
  47.  
  48. mkdir -p /storage/share/samba/public_files/all
  49. mkdir -p /storage/share/samba/public_files/exchange
  50. mkdir -p /storage/share/samba/public_files/privat/
  51.  
  52. chown smbadmin:smbgroup /storage/share/samba/public_files
  53. chown smbadmin:smbgroup /storage/share/samba/public_files/all
  54. chown smbadmin:smbgroup /storage/share/samba/public_files/exchange
  55. chown smbadmin:smbadmin /storage/share/samba/public_files/privat/
  56.  
  57. chmod -R ugo-rwx /storage/share/samba/public_files/
  58. chmod u+rwx,g+rxs,o+rx /storage/share/samba/public_files/
  59. chmod u+rwx,g+rwxs,o+rx /storage/share/samba/public_files/all
  60.  
  61. chmod u+rwx,g+rxs,o+rx /storage/share/samba/public_files/exchange
  62. setfacl -m u:user1:rwx /storage/share/samba/public_files/exchange
  63.  
  64. chmod u-rwx,g-rwxs,o-rwx /storage/share/samba/public_files/privat/
  65. chmod -R u+rwx,g+rwx-s,o-rwx /storage/share/samba/public_files/privat/
  66. setfacl -m u:user1:rwx /storage/share/samba/public_files/privat/
  67.  
  68. #remove permission when need
  69. #setfacl -x u:user1 /storage/share/samba/public_files/privat/
  70.  
  71. touch /storage/share/samba/public_files/all/.lock
  72. chmod go-rwx /storage/share/samba/public_files/all/.lock
  73. chattr +i /storage/share/samba/public_files/all/.lock
  74.  
  75. touch /storage/share/samba/public_files/exchange/.lock
  76. chmod go-rwx /storage/share/samba/public_files/exchange/.lock
  77. chattr +i /storage/share/samba/public_files/exchange/.lock
  78.  
  79. touch /storage/share/samba/public_files/privat/.lock
  80. chmod go-rwx /storage/share/samba/public_files/privat/.lock
  81. chattr +i /storage/share/samba/public_files/privat/.lock
  82.  
  83. systemctl restart smbd
  84. systemctl restart nmbd
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement