当前位置:   article > 正文

在Ubuntu中安装Samba文件服务

ubuntu 安装samba

点击蓝字 关注我们

First Frost

在Ubuntu中安装Samba文件服务

    Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,而SMB是Server Message Block的缩写,即为服务器消息块 ,SMB主要是作为Microsoft的网络通讯协议,后来Samba将SMB通信协议应用到了Linux系统上,就形成了现在的Samba软件。后来微软又把 SMB 改名为 CIFS(Common Internet File System),即公共 Internet 文件系统,并且加入了许多新的功能,这样一来,使得Samba具有了更强大的功能。

安装 samba 服务

 
 
  1. root@v:~# apt install samba samba-common
  2. root@v:~#

创建共享目录

 
 
  1. root@v:~# mkdir /cby/smb/ -pv
  2. root@v:~# chmod 777 -R /cby/smb/
  3. root@v:~#

修改配置文件

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

重启服务

 
 
  1. root@v:~# systemctl restart smbd
  2. root@v:~#

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、51CTO、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

文章主要发布于微信公众号

6806dacbc6e9e5252b8aac5473eb88f4.jpeg

小陈运维

微信号

小陈运维

全网搜索

小陈运维

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

闽ICP备14008679号