Redhat_rhel8.0_SAMBA服务搭建步骤

Redhat_rhel8.0_SAMBA服务搭建详细

一、1991年时,大学生Tridgwell为了解决Linux与Windows系统之间共享文件的问题,便开发出SMB协议与Sanba服务程序。其中SMB协议:实现局域网内文件或者打印机等资源共享服务的协议。

二、搭建方式:

2.1、准备一台redhat_8.0、前提是完成网络和YUM源的配置,在我博客其他文章有所写到,欢迎观看。

2.2、 samba服务器Server Redhat_rhel8.0 10.5.100.125
2.2、 samba客户端Client Windows 10.5.100.100
2.2、 samba客户端Server Redhat_rhel8.0 10.5.100.126
2.3、 Windows_10客户端访问samba服务器
2.4、 samba客户端访问samba服务器

三、samba_Server服务器安装samba服务

[root@localhost yum.repos.d]# yum install samba -y

3.1、查看samba安装情况

[root@wh-pc-yanyr ~]# rpm -qa | grep samba
samba-common-tools-4.12.3-12.el8.3.x86_64
samba-4.12.3-12.el8.3.x86_64
samba-common-libs-4.12.3-12.el8.3.x86_64
samba-common-4.12.3-12.el8.3.noarch
samba-client-libs-4.12.3-12.el8.3.x86_64
samba-libs-4.12.3-12.el8.3.x86_64

3.2、重启samba服务

[root@wh-pc-yanyr ~]# systemctl start smb.service
[root@wh-pc-yanyr ~]# systemctl start nmb.service
[root@wh-pc-yanyr ~]# systemctl enable smb.service
[root@wh-pc-yanyr ~]# systemctl enable nmb.service

3.3、创建共享资源目录,并给予权限

[root@wh-pc-yanyr ~]# mkdir -p /sambadir/share
[root@wh-pc-yanyr ~]# chmod 777 /sambadir/share/

3.4、编辑配置文件

[root@wh-pc-yanyr ~]# vim /etc/samba/smb.conf
//写入以下配置信息:
Redhat_rhel8.0_SAMBA服务搭建步骤_第1张图片

3.5、测试smb.conf文件语法是否错误

[root@wh-pc-yanyr ~]# testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.

3.6、关闭SELINUX属于内核的安全服务会阻止外部访问

[root@localhost ]# vim /etc/sysconfig/selinux
修改:SELINUX=disabled

3.7、关闭防火墙

[root@localhost ]# systemctl stop firewalld //关闭服务:
[root@localhost ]# systemctl disable firewalld //关闭开机启动:

3.8、重启samba服务

[root@localhost ]# systemctl restart smb.service
[root@localhost ]# systemctl restart nmb.service

3.9、创建系统用户、以及提升为samba用户

[root@localhost ]#useradd sambauser1
[root@localhost ]#pdbedit -a -u sambauser1
//设置密码*****

3.10、使用Windows_10 验证主机共享结果
Redhat_rhel8.0_SAMBA服务搭建步骤_第2张图片
至此Windows与rhel_8,samba服务器访问成功!

四、rhel_8客户端访问rhel_8服务器

一、Samba客户端配置

1.1、查看是否有安装samba-client,cifs-utils软件包

[root@localhost ~]# rpm -qa samba-client samba cifs-utils

1.2、安装samba、samba-client 、cifs-utils客户端软件包

[root@localhost ~]# yum install samba samba-client cifs-utils -y

1.3、创建用户并设置为samba用户

[root@localhost ~]# useradd sambauser
[root@localhost ~]# smbpasswd -a sambauser

1.4、创建挂载点

[root@localhost ~]# mkdir /sambadir/share/

1.5、给予执行权限,防止挂载不上

[root@localhost ~]# setfacl -m u:sambauser:rwx /sambadir/

1.6、写入/etc/fstab挂载

//10.5.100.125/share /sambadir/share cifs defaults,username=sambauser,password=sambauser 0 0
//其中IP写SAMBA服务器的IP

1.7、挂载所有/etc/fstab配置文件

[root@localhost ~]# mount -a

1.8、验证共享结果

[root@localhost ~]# \10.5.100.125
bash: \10.5.100.125: command not found…
Failed to search for file: Cannot update read-only repo
[root@localhost ~]#
[root@localhost ~]# cd /sambadir/share/
[root@localhost share]# ls
qinjie1
[root@localhost share]#

Redhat_rhel8.0_SAMBA服务搭建步骤_第3张图片
至此rhel_8,samba客户端与rhel_8,samba服务器访问成功!

你可能感兴趣的:(linux,centos,samba,rhel)