SAMBA介绍
SMB:Server Message Block 服务器消息块,IBM发布,最早是DOS网络文件共享协议<br /> CIFS:common internet file system,微软基于SMB发布<br /> SAMBA:1991年Andrew Tridgell,实现 windows和UNIX相通<br /> 官方网站:[http://www.samba.org/](http://www.yunweipai.com/go?_=8b2f8fabcbaHR0cDovL3d3dy5zYW1iYS5vcmcv)<br />SAMBA的功能:<br /> 1.共享文件和打印,实现在线编辑<br /> 2.实现登录SAMBA用户的身份认证<br /> 3.可以进行NetBIOS名称解析<br /> 4.外围设备共享<br />Windows计算机网络管理模式:<br /> 1.工作组WORKGROUP:计算机对等关系,帐号信息各自管理<br /> 2.域DOMAIN:C/S结构,帐号信息集中管理,DC,AD<br />samba软件介绍<br /> 相关包:<br /> samba 提供smb服务<br /> samba-client 客户端软件<br /> samba-common 通用软件<br /> cifs-utils smb客户端工具<br /> samba-winbind 和AD相关<br /> 相关服务进程:<br /> smbd 提供smb(cifs)服务 TCP:139,445<br /> nmbd NetBIOS名称解析 UDP:137,138<br /> 主配置文件:/etc/samba/smb.conf 帮助参看:man smb.conf
基础环境
镜像 | 虚拟机 | IP地址 |
---|---|---|
CentOS-7-x86_64-DVD-1511.iso | WMware15.5 pro | 192.168.200.10 |
SAMBA部署
[root@localhost ~]# hostnamectl set-hostname samda
[root@localhost ~]# bash
[root@samda ~]#
[root@samda ~]#
[root@samda ~]# hostnamectl
Static hostname: samda
Icon name: computer-vm
Chassis: vm
Machine ID: eefd7b411d7347bdac743e0d446ba0b4
Boot ID: 0ea3f72a474f4542bbf3be2ef30ff74c
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@samda ~]# yum install -y samba
[root@samda ~]# vim /etc/samba/smb.conf
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = no //把yes改成no
cups options = raw
disable spoolss=yes //添加这一行
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
//添加下面这些文件
[share]
path = /opt/share
browseable = yes
public = yes
writable = yes
[root@samda ~]# mkdir /opt/share
[root@samda ~]#
[root@samda ~]# chmod 777 /opt/share/
[root@samda ~]# systemctl start smb
[root@samda ~]# 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 3003/smbd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1444/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1964/master
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 3003/smbd
tcp6 0 0 :::3306 :::* LISTEN 1900/mysqld
tcp6 0 0 :::139 :::* LISTEN 3003/smbd
tcp6 0 0 :::22 :::* LISTEN 1444/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1964/master
tcp6 0 0 :::445 :::* LISTEN 3003/smbd
[root@samda ~]# smbpasswd -a root
New SMB password:
Retype new SMB password:
Added user root.
[root@samda ~]# service smb restart
Redirecting to /bin/systemctl restart smb.service
[root@samda ~]# systemctl restart smb
[root@samda ~]#
[root@samda ~]# systemctl stop firewalld
[root@samda ~]# setenforce 0
参数说明:
⚫ /opt/share:这个目录是将要共享的目录,若没有,需要创建。
⚫ browseable:参数是操作权限;
⚫ public:参数是访问权限;
⚫ writable:参数是对文件的操作权限。
使用 Samba 服务
1.配置完成后win+R打开运行
2.输入创建好的root用户
3,进入samba (share)就是我们创建的共享用户
增加其他用户访问
//直接创建一个smb用户
[root@samda ~]# useradd -s /sbin/nologin bai
[root@samda ~]# smbpasswd -a bai
New SMB password:
Retype new SMB password:
Added user bai.
进入 cmd 命令行输入如下命令清空 samba 登录记录
之后步骤跟前面一样