当前位置:   article > 正文

samba 服务搭建 (ubuntu20.04)_sambda

sambda
  1. #1、移除旧版本
  2. $sudo apt-get autoremove samba samba-common
  3. #2、安装sambda服务
  4. $sudo apt-get install samba samba-common
  5. #3、设置共享目录
  6. $sudo mkdir -p /var/study
  7. $sudo chmod 777 /var/study
  8. #(默认 drwxrwxrwx 2 root root 4096 Sep 17 06:20 study/ )
  9. $udo chown nobody:nogroup /var/study
  10. #4、添加 samba用户
  11. $ sudo smbpasswd -a hzmct
  12. New SMB password: # 密码为 hzmct
  13. #5、添加共享目录
  14. $sudo vim /etc/samba/smb.conf
  15. [study]
  16. comment = mysambda
  17. path = /var/study
  18. writeable = yes
  19. browseable=yes
  20. create mask=0777
  21. directory mask=0777
  22. guest ok=yes
  23. #6、 解决方法 Failed to restart smbd.service: Unit smbd.service is masked.
  24. $sudo systemctl unmask smbd
  25. $sudo systemctl enable smbd
  26. $sudo systemctl restart smbd
  27. $sudo systemctl status smbd

我的配置文件 vim /etc/samba/smb.conf 为:

  1. #
  2. # Sample configuration file for the Samba suite for Debian GNU/Linux.
  3. #
  4. #
  5. # This is the main Samba configuration file. You should read the
  6. # smb.conf(5) manual page in order to understand the options listed
  7. # here. Samba has a huge number of configurable options most of which
  8. # are not shown in this example
  9. #
  10. # Some options that are often worth tuning have been included as
  11. # commented-out examples in this file.
  12. # - When such options are commented with ";", the proposed setting
  13. # differs from the default Samba behaviour
  14. # - When commented with "#", the proposed setting is the default
  15. # behaviour of Samba but the option is considered important
  16. # enough to be mentioned here
  17. #
  18. # NOTE: Whenever you modify this file you should run the command
  19. # "testparm" to check that you have not made any basic syntactic
  20. # errors.
  21. #======================= Global Settings =======================
  22. [global]
  23. ## Browsing/Identification ###
  24. # Change this to the workgroup/NT-domain name your Samba server will part of
  25. workgroup = WORKGROUP
  26. # server string is the equivalent of the NT Description field
  27. server string = %h server (Samba, Ubuntu)
  28. # Windows Internet Name Serving Support Section:
  29. # WINS Support - Tells the NMBD component of Samba to enable its WINS Server
  30. # wins support = no
  31. # WINS Server - Tells the NMBD components of Samba to be a WINS Client
  32. # Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
  33. ; wins server = w.x.y.z
  34. # This will prevent nmbd to search for NetBIOS names through DNS.
  35. dns proxy = no
  36. #### Networking ####
  37. # The specific set of interfaces / networks to bind to
  38. # This can be either the interface name or an IP address/netmask;
  39. # interface names are normally preferred
  40. ; interfaces = 127.0.0.0/8 eth0
  41. # Only bind to the named interfaces and/or networks; you must use the
  42. # 'interfaces' option above to use this.
  43. # It is recommended that you enable this feature if your Samba machine is
  44. # not protected by a firewall or is a firewall itself. However, this
  45. # option cannot handle dynamic or non-broadcast interfaces correctly.
  46. ; bind interfaces only = yes
  47. #### Debugging/Accounting ####
  48. # This tells Samba to use a separate log file for each machine
  49. # that connects
  50. log file = /var/log/samba/log.%m
  51. # Cap the size of the individual log files (in KiB).
  52. max log size = 1000
  53. # If you want Samba to only log through syslog then set the following
  54. # parameter to 'yes'.
  55. # syslog only = no
  56. # We want Samba to log a minimum amount of information to syslog. Everything
  57. # should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
  58. # through syslog you should set the following parameter to something higher.
  59. syslog = 0
  60. # Do something sensible when Samba crashes: mail the admin a backtrace
  61. panic action = /usr/share/samba/panic-action %d
  62. ####### Authentication #######
  63. # Server role. Defines in which mode Samba will operate. Possible
  64. # values are "standalone server", "member server", "classic primary
  65. # domain controller", "classic backup domain controller", "active
  66. # directory domain controller".
  67. #
  68. # Most people will want "standalone sever" or "member server".
  69. # Running as "active directory domain controller" will require first
  70. # running "samba-tool domain provision" to wipe databases and create a
  71. # new domain.
  72. server role = standalone server
  73. # If you are using encrypted passwords, Samba will need to know what
  74. # password database type you are using.
  75. passdb backend = tdbsam
  76. obey pam restrictions = yes
  77. # This boolean parameter controls whether Samba attempts to sync the Unix
  78. # password with the SMB password when the encrypted SMB password in the
  79. # passdb is changed.
  80. unix password sync = yes
  81. # For Unix password sync to work on a Debian GNU/Linux system, the following
  82. # parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
  83. # sending the correct chat script for the passwd program in Debian Sarge).
  84. passwd program = /usr/bin/passwd %u
  85. passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
  86. # This boolean controls whether PAM will be used for password changes
  87. # when requested by an SMB client instead of the program listed in
  88. # 'passwd program'. The default is 'no'.
  89. pam password change = yes
  90. # This option controls how unsuccessful authentication attempts are mapped
  91. # to anonymous connections
  92. map to guest = bad user
  93. ########## Domains ###########
  94. #
  95. # The following settings only takes effect if 'server role = primary
  96. # classic domain controller', 'server role = backup domain controller'
  97. # or 'domain logons' is set
  98. #
  99. # It specifies the location of the user's
  100. # profile directory from the client point of view) The following
  101. # required a [profiles] share to be setup on the samba server (see
  102. # below)
  103. ; logon path = \\%N\profiles\%U
  104. # Another common choice is storing the profile in the user's home directory
  105. # (this is Samba's default)
  106. # logon path = \\%N\%U\profile
  107. # The following setting only takes effect if 'domain logons' is set
  108. # It specifies the location of a user's home directory (from the client
  109. # point of view)
  110. ; logon drive = H:
  111. # logon home = \\%N\%U
  112. # The following setting only takes effect if 'domain logons' is set
  113. # It specifies the script to run during logon. The script must be stored
  114. # in the [netlogon] share
  115. # NOTE: Must be store in 'DOS' file format convention
  116. ; logon script = logon.cmd
  117. # This allows Unix users to be created on the domain controller via the SAMR
  118. # RPC pipe. The example command creates a user account with a disabled Unix
  119. # password; please adapt to your needs
  120. ; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
  121. # This allows machine accounts to be created on the domain controller via the
  122. # SAMR RPC pipe.
  123. # The following assumes a "machines" group exists on the system
  124. ; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
  125. # This allows Unix groups to be created on the domain controller via the SAMR
  126. # RPC pipe.
  127. ; add group script = /usr/sbin/addgroup --force-badname %g
  128. ############ Misc ############
  129. # Using the following line enables you to customise your configuration
  130. # on a per machine basis. The %m gets replaced with the netbios name
  131. # of the machine that is connecting
  132. ; include = /home/samba/etc/smb.conf.%m
  133. # Some defaults for winbind (make sure you're not using the ranges
  134. # for something else.)
  135. ; idmap uid = 10000-20000
  136. ; idmap gid = 10000-20000
  137. ; template shell = /bin/bash
  138. # Setup usershare options to enable non-root users to share folders
  139. # with the net usershare command.
  140. # Maximum number of usershare. 0 (default) means that usershare is disabled.
  141. ; usershare max shares = 100
  142. # Allow users who've been granted usershare privileges to create
  143. # public shares, not just authenticated ones
  144. usershare allow guests = yes
  145. #======================= Share Definitions =======================
  146. # Un-comment the following (and tweak the other settings below to suit)
  147. # to enable the default home directory shares. This will share each
  148. # user's home directory as \\server\username
  149. ;[homes]
  150. ; comment = Home Directories
  151. ; browseable = no
  152. # By default, the home directories are exported read-only. Change the
  153. # next parameter to 'no' if you want to be able to write to them.
  154. ; read only = yes
  155. # File creation mask is set to 0700 for security reasons. If you want to
  156. # create files with group=rw permissions, set next parameter to 0775.
  157. ; create mask = 0700
  158. # Directory creation mask is set to 0700 for security reasons. If you want to
  159. # create dirs. with group=rw permissions, set next parameter to 0775.
  160. ; directory mask = 0700
  161. # By default, \\server\username shares can be connected to by anyone
  162. # with access to the samba server.
  163. # Un-comment the following parameter to make sure that only "username"
  164. # can connect to \\server\username
  165. # This might need tweaking when using external authentication schemes
  166. ; valid users = %S
  167. # Un-comment the following and create the netlogon directory for Domain Logons
  168. # (you need to configure Samba to act as a domain controller too.)
  169. ;[netlogon]
  170. ; comment = Network Logon Service
  171. ; path = /home/samba/netlogon
  172. ; guest ok = yes
  173. ; read only = yes
  174. # Un-comment the following and create the profiles directory to store
  175. # users profiles (see the "logon path" option above)
  176. # (you need to configure Samba to act as a domain controller too.)
  177. # The path below should be writable by all users so that their
  178. # profile directory may be created the first time they log on
  179. ;[profiles]
  180. ; comment = Users profiles
  181. ; path = /home/samba/profiles
  182. ; guest ok = no
  183. ; browseable = no
  184. ; create mask = 0600
  185. ; directory mask = 0700
  186. [printers]
  187. comment = All Printers
  188. browseable = no
  189. path = /var/spool/samba
  190. printable = yes
  191. guest ok = no
  192. read only = yes
  193. create mask = 0700
  194. # Windows clients look for this share name as a source of downloadable
  195. # printer drivers
  196. [print$]
  197. comment = Printer Drivers
  198. path = /var/lib/samba/printers
  199. browseable = yes
  200. read only = yes
  201. guest ok = no
  202. # Uncomment to allow remote administration of Windows print drivers.
  203. # You may need to replace 'lpadmin' with the name of the group your
  204. # admin users are members of.
  205. # Please note that you also need to set appropriate Unix permissions
  206. # to the drivers directory for these users to have write rights in it
  207. ; write list = root, @lpadmin
  208. [share]
  209. comment = mysambda
  210. path = /var/study
  211. writeable = yes
  212. browseable=yes
  213. create mask=0777
  214. directory mask=0777
  215. guest ok=yes

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/182453
推荐阅读
相关标签
  

闽ICP备14008679号