linux文件共享;centos;samba;wsdd2

55gY 2,867 0

需求

需一台服务器作为文件共享使用
要求:多用户,权限控制,白嫖

环境

系统:Centos7
架构:x86_64

安装

Shell
  1. #安装samba
  2. yum install samba samba-client samba-common -y
复制 文本 高亮

NetBios

由于WIN10安全性的原因,你可能不能用主机名\\dav这样的方式访问这个共享,可以选择安装wsdd2来实现NetBios
需要先配置/etc/samba/smb.conf配置文件[global]里面添加netbios name = dav

Shell
  1. #安装gcc编译环境
  2. yum -y install gcc automake autoconf libtool make
  3. #下载并解压wsdd2
  4. tar -zxvf <(curl -Ls https://github.com/Netgear/wsdd2/archive/1.8.7.tar.gz)
  5. #进入wsdd目录
  6. cd wsdd2-1.8.7
  7. #编译wsdd
  8. make CFLAGS=-std=gnu99
  9. #复制编译好的文件到sbin
  10. cp wsdd2 /usr/sbin/
  11. #设置服务项wsdd2.service
  12. vim /lib/systemd/system/wsdd2.service
  13.  
  14. [Unit]
  15. Description=WSD/LLMNR Discovery/Name Service Daemon
  16. BindsTo=smb.service
  17.  
  18. [Service]
  19. ExecStart=/usr/sbin/wsdd2
  20. ExecReload=/bin/kill -HUP $MAINPID
  21. Restart=on-failure
  22. DynamicUser=true
  23. AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
  24. PrivateTmp=true
  25. PrivateDevices=true
  26. ProtectSystem=full
  27. ProtectHome=true
  28.  
  29. [Install]
  30. WantedBy=multi-user.target
  31.  
  32. #重载服务
  33. systemctl daemon-reload
  34. #服务设置开机启动
  35. systemctl enable wsdd2
  36. #启动wsdd2
  37. systemctl start wsdd2
复制 文本 高亮

常用命令

Shell
  1. ##重启服务
  2. service smb restart
  3. ##编辑配置文件
  4. vi /etc/samba/smb.conf
  5. ##验证配置文件
  6. testparm /etc/samba/smb.conf
  7. ##查看所有用户组
  8. cat /etc/group
  9. ##查看所有用户
  10. cat /etc/passwd
  11. ##创建用户组
  12. groupadd
  13. ##创建用户并添加到组
  14. useradd -g 用户名
  15. ##添加共享用户
  16. smbpasswd -a 用户名
  17. ##创建文件夹并设置权限
  18. mkdir -p /home/dav/bak/
  19. chmod -R 0777 /home/dav/bak/
  20. ##关闭防火墙
  21. systemctl disble firewalld
  22. setenforce 0
  23. getenforce
复制 文本 高亮

smb.conf配置文件

Source Code
  1. [global]
  2. #工作组
  3. workgroup = WORKGROUP
  4. #服务器备注
  5. server string = dav
  6. #主机名 \\dav
  7. netbios name = dav
  8. #日志文件
  9. log file = /etc/samba/stdout
  10. #日志大小
  11. max log size = 1000
  12. realm = dav
  13. dns proxy = no
  14. pam password change = yes
  15. #guest用户映射,有效值是"Never"、"Bad User"、"Bad Password"。
  16. map to guest = bad user
  17. usershare allow guests = yes
  18. #建立文件时所给的权限
  19. create mask = 0664
  20. force create mode = 0664
  21. #建立目录时所给的权限
  22. directory mask = 0777
  23. force directory mode = 0775
  24. #指定存取资源时须以此设定的使用者进入才能存取(用户名/@组名)
  25. force user = "root"
  26. #指定存取资源时须以此设定的群组使用者进入才能存取(用户名/@组名)
  27. force group = "root"
  28. follow symlinks = yes
  29. #最大连接数目0代表无限制
  30. max connections = 0
  31. #决定是否装载printcap文件中所有的打印机以供浏览
  32. load printers = no
  33. printing = bsd
  34. printcap name = /dev/null
  35. disable spoolss = yes
  36. strict locking = no
  37. aio read size = 0
  38. aio write size = 0
  39. vfs objects = catia fruit recycle streams_xattr
  40. recycle:keeptree = yes
  41. recycle:maxsize = 0
  42. recycle:repository = .deleted
  43. recycle:versions = yes
  44. #显示中文名
  45. unix charset = UTF-8
  46. dos charset = cp936
  47. #共享文件显示中文名
  48. #client code page = 939
  49. # Security
  50. client ipc max protocol = SMB3
  51. client ipc min protocol = SMB2_10
  52. client max protocol = SMB3
  53. client min protocol = SMB2_10
  54. server max protocol = SMB3
  55. server min protocol = SMB2_10
  56. # Time Machine
  57. fruit:delete_empty_adfiles = yes
  58. fruit:time machine = yes
  59. fruit:veto_appledouble = no
  60. fruit:wipe_intentionally_left_blank_rfork = yes
  61. # Other
  62. ntlm auth = yes
  63. sync always = yes
  64. #共享是否可见
  65. browseable = yes
  66. #游客可见
  67. guest ok = yes
  68. #侦听 NetBIOS
  69. #pid directory = /var/run
  70. #unix extensions = yes
  71. #smb ports = 139
  72. #wins support = yes
  73. #wins proxy = yes
  74. #dgram port = 138
  75. #nbt port = 137
  76. #wins server = 192.168.8.244
  77. #winsdb:local_owner = 2
  78. #关闭netbios
  79. disable netbios = yes
  80. #hostname lookups = yes
  81. [bak]
  82. #目录
  83. path = /bak/金蝶
  84. #共享是否可见
  85. browseable = no
  86. #游客
  87. guest ok = no
  88. #可读写白名单@root为组;root为用户
  89. write list = "@root" "bak"
  90. [guest]
  91. #目录
  92. path = /dav/公共文件
  93. #可读写白名单@root为组;root为用户
  94. write list = "@root"
  95. [pmc]
  96. #目录
  97. path = /dav/计划部
  98. #可读写白名单@root为组;root为用户
  99. write list = "@root"
复制 文本 高亮

本站资源来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。敬请谅解!

发表评论 取消回复
表情 图片 链接 代码