这篇文章主要介绍了 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 服务安装方法,希望对大家有所帮助,如果大家有任何疑问请给我留言。在此也非常感谢大家对网站的支持!
你可能也喜欢
- ♥ RackNerd:站群多 IP 服务器促销,可选洛杉矶和纽约机房,249-421 个可用 IP,月付 145 美元起09/03
- ♥ ChangeIP:美国和欧洲高防 vps,1 核/512MB/20GB SSD/500GB/流量/100Mbps 带宽,$2.99/月起,支持 windows11/12
- ♥ #春节优惠#dogyun:多国 CN2 线路,动态云服务器 7 折,经典云服务器 8 折,充值每满 100 送 10 元,02/08
- ♥ Linux 下网络安装 Debian/Ubuntu/CentOS/Windows 纯净版一键脚本06/08
- ♥ BuyVM:AMD 高性能 VPS+超便宜块存储+1Gbps 带宽(不限流量),少量补货$3.5/月起,可选拉斯维加斯/卢森堡等机房07/30
- ♥ VPS.MR:英国 vps,1 核/1GB 内存/35GB SSD/1TB 流量/1Gbps 带宽,£6.99/月起03/02







