这篇文章主要介绍了 Centos 7 Samba 服务安装方法,本文给大家介绍的非常详细,具有一定的参考借鉴价值 ,需要的朋友可以参考下:
搭建 Samba 服务器是为了实现 Linux 共享目录之后,在 Windows 可以直接访问该共享目录。
查看是已安装samba包:
这里列出所有已安装的 samba 包,但是现在 samba 服务还未安装。
安装 Samba 服务
yum install -y samba
使用 yum 安装是因为安装时会自动检测需要的依赖并安装。
1 2 3 4 5 6 7 8 9 10 11 12 | Dependencies Resolved============================================================================================================ Package Arch Version Repository Size============================================================================================================Installing: samba x86_64 4.8.3-4.el7 base 680 kInstalling for dependencies: pytalloc x86_64 2.1.13-1.el7 base 17 k samba-common-tools x86_64 4.8.3-4.el7 base 448 k samba-libs x86_64 4.8.3-4.el7 base 276 kTransaction Summary============================================================================================================ |
Samba 配置
至此,我们已经将 Samba 安装完毕,现在进行 Samba 的配置。
• 关闭 selinux 服务
该服务不关闭会导致 Windows 没有访问权限
临时关闭
setenforce 0(只对当前有效,重启后,该服务又会重新启动。)
永久关闭
打开 selinux 的配置文件:
vi /etc/sysconfig/selinux
将 SELINUX=enforcing 修改为 SELINUX=disabled
1 2 3 4 5 6 7 8 9 10 | #This file controls the state of SELinux on the system.#SELINUX= can take one of these three values:#enforcing - SELinux security policy is enforced.#permissive - SELinux prints warnings instead of enforcing.#disabled - No SELinux policy is loaded.SELINUX=disabled#SELINUXTYPE= can take one of these two values:#targeted - Targeted processes are protected,#mls - Multi Level Security protection.SELINUXTYPE=targeted |
重启 :reboot
•创建共享目录
在 home 目录新建共享目录
mkdir /home/share
赋予目录权限
chmod 777 /home/share
• 添加 samba 服务器用户
首先创建一个普通用户
1 2 | adduser fenxiangpasswd fenxiang |
将该用户添加到 samba 服务列表中
1 2 3 4 5 6 | smbpasswd –a fenxiang------------------------New SMB password:Retype new SMB password:Added user fenxiang.------------------------ |
出现 Added user *表示添加成功
•修改 Samba 配置文件
首先备份 Samba 配置文件:
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
打开配置文件:
vi /etc/samba/smb.conf
做如下修改:
security = user
#这里是设置 samba 的共享级别,share 表示共享级访问,服务器不对客户机进行身份认证,user 表示用户级访问,被访问的 samba 服务器要对客户机进行身份验证
在配置文件最后添加以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [share]comment = my share#对该共享资源的说明path = /home/share#共享资源的路径valid user = fenxiang#设置允许访问共享的用户或组的列表writable = yes#指定共享的路径是否可写browseable = yes#是否可以浏览共享目录create mode = 0777#指定客户机在共享目录中创建文件的默认权限directory mode = 0777#指定客户机共享目录中创建文件目录的默认权限 |
保存退出
•关闭防火墙
关闭防火墙
systemctl stop firewalld
关闭防火墙开机启动
systemctl disable firewalld
• 启动 samba 服务
开启服务
1 2 | systemctl start smb systemctl start nmb |
将服务加入到开机启动中
1 2 | systemctl enable smbsystemctl enable nmb |
• Windows 访问
总结
以上所述是小编给大家介绍的 Centos 7 Samba 服务安装方法,希望对大家有所帮助,如果大家有任何疑问请给我留言。在此也非常感谢大家对网站的支持!
你可能也喜欢
- ♥ Hosteons:美国 OpenVZ 7 VPS,1 核/256MB 内存/5G 硬盘/不限流量/100Mbps 带宽,$12/年起09/20
- ♥ #套餐整理#RackNerd:洛杉矶 DC02 机房 VPS 补货,$9.89/年起,可选洛杉矶/西雅图/纽约/芝加哥/亚特兰大/阿什本10/11
- ♥ Sharktech:4 月美国服务器促销,丹佛机房,Dual Xeon E5-2678V3/128 GB/1TB NVME M.2,1Gbps 不限流量,60Gbps 基本 DDoS 保护,月付 $12904/05
- ♥ CloudCone:美国服务器优惠,E3/16G/1T SSD,可选 100M 不限流量或 1Gbps 月流量 40TB,首月$68,次月免费03/13
- ♥ onetechcloud:高速 VPS 新春 8 折优惠,可选香港 cn2、美国 cn2(cera、安畅)02/08
- ♥ TMTHosting:西雅图 VPS 全场 75 折循环优惠,斯巴达同款美国西雅图高防 VPS,3.33 美元/月起,支持支付宝/微信支付/Paypal03/29







