CentOS 7 安装 samba

CentOS 7 安装Samba

1、使用yum -y install samba samba-client samba-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

2、在配置文件末尾开始配置,添加如图内容

# vi /etc/samba/smb.conf


[global]
        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 restart smb

# systemctl enable smb

# systemctl status smb

2、Linux上测试

#smbclient -L localhost -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

b、弹出共享目录,双击workspace,输入之前配置的用户名密码,即可操作samba共享的文件



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值