Linux装配—9.Samba


Samba是Linux系统上实现SMB协议的免费C/S软件,实现跨平台文件共享

SMB(Server Messages Block)信息服务块是在局域网共享文件和打印机的通信协议


基本概述

1、安装启动

[root@wg ~]# yum -y install samba samba-client
# samba 服务端
# samba-client 客户端 提供了smbclient命令
# samba依赖于rpc服务,没有需安装

[root@wg ~]# systemctl start nmb smb
[root@wg ~]# systemctl enable nmb smb

[root@localhost vsftpd]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address   Foreign Address    State     PID/Program name    
tcp        0      0 0.0.0.0:139     0.0.0.0:*          LISTEN    3662/smbd           
tcp        0      0 0.0.0.0:111     0.0.0.0:*          LISTEN    937/rpcbind                              
tcp        0      0 0.0.0.0:445     0.0.0.0:*          LISTEN    3662/smbd           

2、配置文件

[root@wg ~]# /etc/samba/smb.conf
| [global]
|         workgroup = SAMBA
|         security = user
| 
|         passdb backend = tdbsam
| 
|         printing = cups
|         printcap name = cups
|         load printers = yes
|         cups options = raw
| 
| [homes]
|         comment = Home Directories
|         valid users = %S, %D%w%S
|         browseable = No
|         read only = No
|         inherit acls = Yes
| 
| [printers]
|         comment = All Printers

[root@wg ~]# vi /etc/samba/smb.conf.example
| #=========== Global Settings ===========
| [global]
|      workgroup = WORKGROUP                    // 组名称
|      # 这里设置的是在网上邻居能找到
|      server string = Samba Server Version %v  // 描述
|
| ;    netbios name = MYSERVER
|
| ;    interfaces = lo eth0
| ;    hosts allow = 127. 192.168.3.
| # ------- Standalone Server Options -------
|         security = user                       // 安全认证级别
|         passdb backend = tdbsam
|
| #=========== Share Definitions ============
| [homes]                                       // 共享名
|        comment = Home Directories             // 描述
|        browseable = no                        // 是否隐藏共享
|        writable = yes                         // 是否允许写入
| ;      valid users = %S                       // 允许谁访问;组用 @组名
| ;      valid users = MYDOMAIN\%S              
| 
| [printers]
|        comment = All Printers
|        path = /var/spool/samba                 
|        browseable = no
|        guest ok = no                           // 是否允许来宾访问
|        writable = no
|        printable = yes                         // 是否允许打印机
| 
| # Un-comment the following and create the netlogon directory for Domain Logons:
| ;      [netlogon]
| ;      comment = Network Logon Service
| ;      path = /var/lib/samba/netlogon
| ;      guest ok = yes
| ;      writable = no
| ;      share modes = no
| 
| # Un-comment the following to provide a specific roaming profile share.
| # The default is to use the user's home directory:
| ;      [Profiles]
| ;      path = /var/lib/samba/profiles
| ;      browseable = no
| ;      guest ok = yes
| 
| # A publicly accessible directory that is read only, except for users in the
| # "staff" group (which have write permissions):
| ;      [public]
| ;      comment = Public Stuff
| ;      path = /home/samba
| ;      public = yes
| ;      writable = no
| ;      printable = no
| ;      write list = +staff
|

- samba4种安全认证级别:
| share: 不需要账号密码 公开共享
| user: 需要提供sam账号密码才能访问共享,私密共享
| server: 依靠其他windows 或 samba来验证用户,是代理验证
| domain: 域安全级别,使用主域控制器(PDC)来完成认证

搭建示例

相关