这篇文章主要介绍了 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 k Installing 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 k Transaction 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<br />
• 添加 samba 服务器用户
首先创建一个普通用户
1 2 | adduser fenxiang passwd 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 smb systemctl enable nmb |
• Windows 访问
总结
以上所述是小编给大家介绍的 Centos 7 Samba 服务安装方法,希望对大家有所帮助,如果大家有任何疑问请给我留言。在此也非常感谢大家对网站的支持!
本文为原创文章,版权归主机之家测评所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ raksmart:洛杉矶新品秒杀 E3-1230 仅 30 美金限量秒杀,新增洛杉矶+韩国站群,爆款 VPS 仅$ 1.9904/29
- ♥ Locvps:香港/新加坡 VPS,8 折优惠,1 核/2G 内存/20G SSD/150G 流量/50Mbps 带宽,252 元/年起04/23
- ♥ Legionbox:E5/16GB/1Gbps 月流量 10TB 起/可选美国、德国和瑞士独立服务器$69/月起06/17
- ♥ VPSDime:便宜 Windows VPS,10Gbps 大带宽,可选美国/荷兰机房,4G 内存/2 核/50gSSD/4T 流量,低至$7/月01/06
- ♥ DesiVPS:圣何塞机房 1Gbps 不限流量 vps 年付 18.99 美元起,10Gbps 带宽 vps 年付 17 美元起,独服$120/月起04/24
- ♥ #11.11#墨云:国内高防云服务器低至 199/3 个月,2*E5-2686V4 电信 50Mbps 带宽 100G 高防物理机 700/月11/02