这篇文章主要介绍了 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 服务安装方法,希望对大家有所帮助,如果大家有任何疑问请给我留言。在此也非常感谢大家对网站的支持!
你可能也喜欢
- ♥ 野草云:2022 年 4 月促销,香港独立服务器,BGP 线路 199 元/月起,华为云三线混合网络 399 元/月起,CN2+BGP 线路 299 元/月起,华为云线路云服务器 99 元/月04/20
- ♥ 亚洲云端:香港云服务器(cn2 gia),6 折优惠,1G 内存/1 核/30gSSD/2T 流量,有 Windows02/04
- ♥ SpartanHost(斯巴达):西雅图机房,Cera 联通 CUVIP 线路,10Gbps 大带宽,20G 高防,优惠后最低月付 2.8 美元09/05
- ♥ Chia 币矿机,美国机房现货,超大 SSD 或 SSD,1Gbps 带宽+不限流量,PayPal/支付宝05/15
- ♥ YunLayer:香港 CN2 GIA 线路 VPS/100Mbps 大带宽,7 折优惠 28 元/月起,可选洛杉矶/香港/日本等机房05/12
- ♥ #兔年春节促销#RackNerd:美国便宜 VPS,低至$10.18/年,可选洛杉矶/西雅图/圣何塞/达拉斯/芝加哥/新泽西/亚特兰大/纽约01/13







