CentOS 7 安装Samba
1、使用yum-yinstallsambasamba-clientsamba-common安装Samba
2、查看Samba版本信息rpm -qi samba如下
Name : samba
Epoch : 0
Version : 4.4.4
Release : 12.el7_3
Architecture: x86_64
Install Date: Wed 26 Apr 2017 06:36:53 AM EDT
Group : System Environment/Daemons
Size : 1869273
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256,Wed 18 Jan 2017 08:01:25 AM EST,Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.4.4-12.el7_3.src.rpm
Build Date : Tue 17 Jan 2017 02:10:29 PM EST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and
Unix
配置Samba服务器
1、 备份原有的配置文件
#cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
#vi /etc/samba/smb.conf
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[CentOS_7.3.1611]
comment = Printer Drivers
path = /home/work/workspace
create mask = 0777
directory mask = 0777
writable = yes
public = yes
read only = no
browseable = yes
valid users = work
[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 = root
create mask = 0664
directory mask = 0775
browseable = yes
valid users = work
创建SAMBA用户
例如:#smbpasswd -a work (此处work必须为linux用户名字中的一个,不能另起一个名字)
如果windows下登录samba服务器后无法访问linux下共享目录,提示没有权限
a、确保linux下防火墙关闭或者是开放共享目录权限:
systemctl stop firewalld.service #停止防火墙
systemctl disable firewalld.service #禁用防火墙
修改目录权限
#chmod -R 777 /home/work/workspace
b、确保samba服务器配置文件smb.conf设置没有问题,可网上查阅资料看配置办法
c、确保setlinux关闭,可以用setenforce 0命令执行。 默认的,SELinux禁止网络上对Samba服务器上的共享目录进行写操作,即使你在smb.conf中允许了这项操作。 /usr/bin/setenforce 修改SELinux的实时运行模式
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
如果要彻底禁用SELinux 需要在/etc/sysconfig/selinux中设置参数selinux=0 ,或者在/etc/grub.conf中添加这个参数
测试连接
1、查看服务
#systemctl restartsmb
#systemctl enablesmb
#systemctl statussmb
2、Linux上测试
#smbclient -Llocalhost-U work效果如下
Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4]
Sharename Type Comment
--------- ---- -------
CentOS_7.3.1611 Disk Printer Drivers
print$ Disk Printer Drivers
IPC$ IPC IPC Service (Samba 4.4.4)
work Disk Home Directories
Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4]
Server Comment
--------- -------
Workgroup Master
--------- -------
3、Windows7上测试
a、win+r快捷键打开运行窗口,输入\\ip\目录(其中目录可不写)
\\192.168.126.128
原文链接:https://www.f2er.com/centos/377807.html