1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > samba文件共享(匿名用户共享 本地用户共享 windows+linux系统之间的共享)

samba文件共享(匿名用户共享 本地用户共享 windows+linux系统之间的共享)

时间:2024-06-16 06:50:02

相关推荐

samba文件共享(匿名用户共享 本地用户共享 windows+linux系统之间的共享)

理论基础:

samaba 共享

samaba:使用smb协议的应用程序 主要用于文件共享

区别:

nfs实现同系统之间的共享 linux--linux

samba服务实现的是不同系统 linux--windows 使用tcp或者udp传输 采用C/S架构

nfs 自动 文件系统类型 nfs

samaba 挂载 自动挂载 文件系统类型 cifs

samba里面包含两个程序 :smbd 、nmbd

smbd为client提供共享资源

nmbd负责主机间的主机名解析

samaba作用

1.可以做存储

2.可以进行文件共享(不同系统之间的共享)

samba实验

server 192.168.2.10

client 192.16.2.20

1.匿名用户共享

服务端配置

1.先安装samaba服务

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

安装完后创建一个名为samaba的目录

[root@localhost ~]# mkdir /samba

2.进行编辑

[root@localhost ~]# vim /etc/samba/smb.conf

保存退出 重启

[root@localhost ~]# systemctl restart smb

3.放行防火墙

[root@localhost ~]# firewall-cmd --add-service=samba --permanent

success

[root@localhost ~]# firewall-cmd --reload

Success

客户端配置

查看是否有这两个程序 如果没有则用yum安装

[root@localhost ~]# rpm -q samba-client

samba-client-4.4.4-9.el7.x86_64

[root@localhost ~]# rpm -q cifs-utils

cifs-utils-6.2-9.el7.x86_64

查看是否能链接到服务端

[root@localhost ~]# smbclient -L 192.168.2.10

到客户端挂载服务端

[root@localhost ~]# mkdir /client

[root@localhost ~]# mount -t cifs //192.168.2.10/pub /client/ -o guest

# 要用匿名用户 所以加-o

验证

服务端创建数据

[root@localhost ~]# cd /samba/

[root@localhost samba]# touch hhhh

[root@localhost samba]# ls

Hhhh

到客户端就可以看到数据了

[root@localhost ~]# cd /client/

[root@localhost client]# ls

hhhh

二、本地用户共享

1.先进去把匿名用户那行给注释掉

[root@localhost ]# vim /etc/samba/smb.conf

#map to guest= Bad user

[public]

comment = public

path = /samba-share

public = no

writable =yes

browseable=yes

2.创建一个新的共享目录

[root@localhost ~]# mkdir /samba-share

3.创建一个用户并设置密码 完后重启服务

[root@localhost ~]# useradd test

[root@localhost ~]# smbpasswd -a test

[root@localhost ~]# systemctl restart smb

到客户端配置

创建一个目录

[root@localhost ~]# mkdir /samba-client

挂载 #-o 用户

[root@localhost ~]# mount -t cifs //192.168.2.10/public /samba-client/ -o user=test,password=

创建数据并验证

[root@localhost ~]# cd /samba-client/

[root@localhost samba-client]# ls

hhhhhhj

---------------------------------------------------------------------------------------------------------------

三.windows+linux系统之间的共享

需要先将虚拟机连接上网

创建目录

[root@localhost ~]# mkdir /data

修改配置文件

[root@localhost ~]# vim /etc/samba/smb.conf

[aa]

comment = aa

path = /data

valid users= aa

write list = aa

public = no

create mask = 0644

directory mask = 0755

创建aa 用户

[root@localhost ~]# useradd aa

[root@localhost ~]# smbpasswd -a aa

New SMB password:

Retype new SMB password:

Added user aa.

先赋予权限

[root@localhost ~]# chown aa:aa /data/

windos配置

网络---搜索---\\192.168.2.10(samba服务上的ip)---aa------确定

验证:

[root@localhost ~]# cd /data/

[root@localhost data]# touch 1

[root@localhost data]# ls

1

右键点击映射网络驱动器可作为永久

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。