网站三个月没排名,新型网络营销方式,关于wordpress 反馈,婚礼网配置与管理samba服务器
1#xff0c;作用#xff1a;可以使用户在异构网络操作系统之间进行文件系统共享
2#xff0c;**SMB协议#xff1a;**主要是作为Microsoft网络的通讯协议#xff1b;一般端口使用为139#xff0c;445。
3#xff0c;功能#xff1a;1#x…配置与管理samba服务器
1作用可以使用户在异构网络操作系统之间进行文件系统共享
2**SMB协议**主要是作为Microsoft网络的通讯协议一般端口使用为139445。
3功能1文件和打印机共享。2身份验证和权限设置。3名称解析。4浏览服务
4工作原理
工作原理
安装samba服务器
#安装准备工作 利用centos7的光盘映射文件[其实就是通过镜像制作本地yum源]
1#创建目录并挂载
[rootlocalhost ~]# mkdir /mnt/iso
[rootlocalhost ~]# mount -o loop /root/CentOS-7-x86_64-DVD-2003.iso /mnt/iso/
mount: /dev/loop0 is write-protected, mounting read-only2#制作yum源文件/etc/yum.repos.d/iso.repo
[rootlocalhost ~]# vim /etc/yum.repos.d/iso.repo
[iso]
nameiso
baseurlfile:///mnt/iso
gpgcheck0
enabled1#安装samba服务
检查是否安装相关的包 #若有则删yum -y remove 包
[rootlocalhost ~]# rpm -qa |grep samba
#安装samba查看软件包详情
[rootlocalhost ~]# yum -y install samba
[rootlocalhost ~]# yum info samba
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Installed Packages
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 18.el7_9
Size : 2.2 M
Repo : installed
From repo : updates
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3 and LGPLv3
Description : Samba is the standard Windows interoperability suite of programs for Linux and: Unix.
#查看samba包
[rootlocalhost ~]# rpm -qa |grep samba
samba-libs-4.10.16-18.el7_9.x86_64
samba-client-libs-4.10.16-18.el7_9.x86_64
samba-common-libs-4.10.16-18.el7_9.x86_64
samba-client-4.10.16-18.el7_9.x86_64
samba-common-4.10.16-18.el7_9.noarch
samba-4.10.16-18.el7_9.x86_64
samba-common-tools-4.10.16-18.el7_9.x86_64
#查看软件包的信息
[rootlocalhost ~]# yum -info samba#samba服务的启动与停止
启动/停止/重启/重新加载/查看状态
systemctl start/stop/restart/relad/status smb.service开机自启systemctl list-unit-files |grep smb配置samba服务器
2 全局变量#[global]主要设置服务器的全局变量格式“字段设定值”
1workgtoup工作组群
2server string说明 #设定samba的注释
3hosts allowIP地址
4security等级
#等级
share:不用账号密码登录服务器访问资源
user:用账号密码登录服务器访问资源
server要账号密码用指定samba服务器登录
domain:要账号密码用Windows域服务器验证
ads:当samba服务器用此等级登录Windows与服务器就具备它的功能但samba服务器不具备有活动目录域控制器的功能5password level位数
6username level位数
7encrypt passwords yes/no #设置是否对samba的密码加密
8map passwd file加密文件 #设定samba的密码文件,后面跟路径例/etc/samba/smbpasswd3 共享服务#主要配置文件/smb.conf
1comment:注释
2path共享资源的完整路径名称
3browseable设置浏览资源时是否显示共享目录 #yes/no
4public设置是否允许匿名访问 ##yes/no
5read only设置是否以可读方式访问共享资源 #yes/no
6wirable设置共享目录是否允许用户写操作 #yes/no
7vaild users设置允许指定的用户或组访问共享资源
8wirte list设置允许写操作的用户或组
#samba访服务的日志文件在 /var/log/samba目录下
#samba服务密码文件在 /tec/samba/smbpasswd目录下#samba服务密码文件
samba账号不能被直接被创建必须存在对应的同名系统账号 #添加账号命令smbpassed
smbpasswd -a 用户名
useadd - passwd - smbpasswd -a配置samba客户端
#linux操作系统中smbclint命令和mount命令访问服务器
smbclient -L 目标IP地址或主机名 -U 登录用户%密码
mount -t cifs//目标IP地址/共享目录名 挂载点 -o username用户名password密码#wondows下测试samba服务器
1方法
-资源管理器-网络-192.168.88.169\public
2方法
-此电脑-映射网络驱动器-Z:-\\192.168.88.169\public
综合案例一 #要求构建一台资源共享服务器实现局域网的文件共享服务文件名WORKGROUP共享目录/mnt/public,共享名public允许所有人访问思路
#1创建目录并在新目录下创建测试文件mkdirtouch
#2编辑samba主配置文件/etc/samba/smb.conf根据格式书写全局变量和共享服务
#3关闭虚拟主机的防火墙关闭虚拟机和selinux防火墙
#4通过Windows测试结果1 #创建目录与测试文件
[rootlocalhost ~]# mkdir /mnt/public
[rootlocalhost ~]# touch /mnt/public/test1.txt
[rootlocalhost ~]# touch /mnt/public/test2.txt2 #修改主配置文件/etc/samba/smb.conf文件
[global]workgroup WORKGOUPsecurity userserver string public Servermap to guest Bad User[public]comment Publicpath /mnt/publicpublic yesbrowseable yesguest ok yes3 #关闭主机的防火墙samba
关闭防火墙selinux服务 #俩防火墙不一样4 #在Windows下测试
1方法
-资源管理器-网络-192.168.88.169\public
2方法
-此电脑-映射网络驱动器-Z:-\\192.168.88.169\public#Linux下测试综合案例二 #某公司需要构建一台资源共享服务器为公司硬件部和软件部两个部门的计算机提供文件共享服务客户端计算机采用用户隔离的方式访问服务器上的资源实现Windows和Linux资源共享。要求硬件部的资料放在samba服务器192.168.88.169的/mnt/hareware目录中软件部的资料放在samba服务器的/mnt/software目录中思路
#分别创建各部的共享目录和测试文件mkdirtouch
#为硬件部添加测试用户和用户组并添加samba账号groupadduseradd -gpasswdsamba -a
#软件部同上
#设置共享目录本地权限chgrpchmod
#配置主配置文件写入组的相关信息
#关闭虚拟机和selinux的防火墙
#Windows测试结果1 #创建目录和测试文件
[rootlocalhost ~]# mkdir /mnt/software
[rootlocalhost ~]# mkdir /mnt/hardware
[rootlocalhost ~]# cd /mnt/software/
[rootlocalhost software]# touch software1.txt software2.txt
[rootlocalhost software]# cd /mnt/hardware/
[rootlocalhost hardware]# touch hardware1.txt hardware2.txt2 #硬件部 添加测试用户和用户组并添加samba账号
[rootlocalhost hardware]# groupadd hardwares
[rootlocalhost hardware]# useradd -g hardwares hardware1
[rootlocalhost hardware]# useradd -g hardwares hardware2
[rootlocalhost hardware]# passwd hardware1
Changing password for user hardware1. #所有密码都是123
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[rootlocalhost hardware]# passwd hardware1 #系统密码
Changing password for user hardware1.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[rootlocalhost hardware]# smbpasswd -a hardware1
New SMB password:
Retype new SMB password:
Added user hardware1.
[rootlocalhost hardware]# smbpasswd -a hardware2 #添加samba账号
New SMB password:
Retype new SMB password:
Added user hardware2.
3 #软件部
[rootlocalhost software]# groupadd softwares
[rootlocalhost software]# useradd -g softwares software1
[rootlocalhost software]# ls
software1.txt software2.txt
[rootlocalhost software]# useradd -g softwares software2
[rootlocalhost software]# passwd software1
Changing password for user software1.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[rootlocalhost software]# passwd software1
Changing password for user software1.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[rootlocalhost software]# smbpasswd -a software1
New SMB password:
Retype new SMB password:
Added user software1.
[rootlocalhost software]# smbpasswd -a software2
New SMB password:
Retype new SMB password:
Added user software2.
4 #设置共享目录的本地权限
[rootlocalhost ~]# chgrp hardwares /mnt/hardware
[rootlocalhost ~]# chgrp softwares /mnt/software
[rootlocalhost ~]# chmod 770 /mnt/hardware/
[rootlocalhost ~]# chmod 770 /mnt/software/
5 #修改主配置文件
[rootlocalhost ~]# vim /etc/samba/smb.conf
[global]workgroup WORKGROUPsecurity userserver string File Server[hsrdwares]comment hardwarespath /mnt/hardwarewritable yesbrowseable yesvaild users hardware[softwares]comment softwarespath /mnt/softwarewritable yesbrowseable yesvaild users softwares5 #重启关闭虚拟机防火墙和selinux的防火墙
[rootlocalhost ~]# systemctl stop firewalld
[rootlocalhost ~]# setenforce 0 #临时关闭
[rootlocalhost ~]# systemctl restart smb
6, #windows测试结果
win键r ---输入ip ---输入账号和密码查看就如下补充永久关闭输入命令vi /etc/selinux/config将SELINUXenforcing改为SELINUXdisabled然后保存退出
火墙 [rootlocalhost ~]# systemctl stop firewalld [rootlocalhost ~]# setenforce 0 #临时关闭 [rootlocalhost ~]# systemctl restart smb 6, #windows测试结果 win键r —输入ip —输入账号和密码查看就如下 [外链图片转存中...(img-64uuNS0Q-1709043635499)]补充永久关闭输入命令vi /etc/selinux/config将SELINUXenforcing改为SELINUXdisabled然后保存退出