SAMBA介绍

  1. SMBServer Message Block 服务器消息块,IBM发布,最早是DOS网络文件共享协议<br /> CIFScommon internet file system,微软基于SMB发布<br /> SAMBA1991Andrew Tridgell,实现 windowsUNIX相通<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部署

  1. [root@localhost ~]# hostnamectl set-hostname samda
  2. [root@localhost ~]# bash
  3. [root@samda ~]#
  4. [root@samda ~]#
  5. [root@samda ~]# hostnamectl
  6. Static hostname: samda
  7. Icon name: computer-vm
  8. Chassis: vm
  9. Machine ID: eefd7b411d7347bdac743e0d446ba0b4
  10. Boot ID: 0ea3f72a474f4542bbf3be2ef30ff74c
  11. Virtualization: vmware
  12. Operating System: CentOS Linux 7 (Core)
  13. CPE OS Name: cpe:/o:centos:centos:7
  14. Kernel: Linux 3.10.0-327.el7.x86_64
  15. Architecture: x86-64
  16. [root@samda ~]# yum install -y samba
  17. [root@samda ~]# vim /etc/samba/smb.conf
  18. [global]
  19. workgroup = SAMBA
  20. security = user
  21. passdb backend = tdbsam
  22. printing = cups
  23. printcap name = cups
  24. load printers = no //把yes改成no
  25. cups options = raw
  26. disable spoolss=yes //添加这一行
  27. [homes]
  28. comment = Home Directories
  29. valid users = %S, %D%w%S
  30. browseable = No
  31. read only = No
  32. inherit acls = Yes
  33. [printers]
  34. comment = All Printers
  35. path = /var/tmp
  36. printable = Yes
  37. create mask = 0600
  38. browseable = No
  39. [print$]
  40. comment = Printer Drivers
  41. path = /var/lib/samba/drivers
  42. write list = @printadmin root
  43. force group = @printadmin
  44. create mask = 0664
  45. directory mask = 0775
  46. //添加下面这些文件
  47. [share]
  48. path = /opt/share
  49. browseable = yes
  50. public = yes
  51. writable = yes
  52. [root@samda ~]# mkdir /opt/share
  53. [root@samda ~]#
  54. [root@samda ~]# chmod 777 /opt/share/
  55. [root@samda ~]# systemctl start smb
  56. [root@samda ~]# netstat -ntpl
  57. Active Internet connections (only servers)
  58. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  59. tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 3003/smbd
  60. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1444/sshd
  61. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1964/master
  62. tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 3003/smbd
  63. tcp6 0 0 :::3306 :::* LISTEN 1900/mysqld
  64. tcp6 0 0 :::139 :::* LISTEN 3003/smbd
  65. tcp6 0 0 :::22 :::* LISTEN 1444/sshd
  66. tcp6 0 0 ::1:25 :::* LISTEN 1964/master
  67. tcp6 0 0 :::445 :::* LISTEN 3003/smbd
  68. [root@samda ~]# smbpasswd -a root
  69. New SMB password:
  70. Retype new SMB password:
  71. Added user root.
  72. [root@samda ~]# service smb restart
  73. Redirecting to /bin/systemctl restart smb.service
  74. [root@samda ~]# systemctl restart smb
  75. [root@samda ~]#
  76. [root@samda ~]# systemctl stop firewalld
  77. [root@samda ~]# setenforce 0

参数说明:
⚫ /opt/share:这个目录是将要共享的目录,若没有,需要创建。
⚫ browseable:参数是操作权限;
⚫ public:参数是访问权限;
⚫ writable:参数是对文件的操作权限。
使用 Samba 服务
1.配置完成后win+R打开运行
image.png
2.输入创建好的root用户
image.png
3,进入samba (share)就是我们创建的共享用户
image.png
增加其他用户访问

  1. //直接创建一个smb用户
  2. [root@samda ~]# useradd -s /sbin/nologin bai
  3. [root@samda ~]# smbpasswd -a bai
  4. New SMB password:
  5. Retype new SMB password:
  6. Added user bai.

进入 cmd 命令行输入如下命令清空 samba 登录记录
image.png
之后步骤跟前面一样

image.pngimage.png