Dragon
主机之家测评主机之家测评  2021-04-21 12:30 主机之家测评 隐藏边栏 |   抢沙发  2 
文章评分 0 次,平均分 0.0

这篇文章主要介绍了 Centos 7 Samba 服务安装方法,本文给大家介绍的非常详细,具有一定的参考借鉴价值 ,需要的朋友可以参考下:

搭建 Samba 服务器是为了实现 Linux 共享目录之后,在 Windows 可以直接访问该共享目录。

查看是已安装samba包:

1
2
3
4
5
6
7
rpm -qa | grep
------------------------------------
-common-4.8.3-4.el7.noarch
-client-libs-4.8.3-4.el7.x86_64
-client-4.8.3-4.el7.x86_64
-common-libs-4.8.3-4.el7.x86_64
------------------------------------

这里列出所有已安装的 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 服务安装方法,希望对大家有所帮助,如果大家有任何疑问请给我留言。在此也非常感谢大家对网站的支持!

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

发表评论

扫一扫二维码分享