欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

用Samba匿名用户搭建共享服务器

程序员文章站 2024-03-13 22:47:46
...
主机名 IP
服务器 192.168.100.100
客户端 192.168.100.129

先完成Samba的安装
先准备搭建的环境和配置
安装软件停掉防火墙

[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#setenforce 0
[root@localhost ~]#yum install samba-* 

安装samba

[root@localhost ~]# yum -y install samba-* //服务端
[root@localhost ~]#  yum -y install samba-* //客户端
启动服务,并加入到开机自启
[root@localhost ~]# systemctl start smb
启动服务,并加入到开机自启
[root@localhost ~]# systemctl start smb
[root@localhost ~]# systemctl enable smb

搭建匿名用户共享服务器,服务端配置,新建共享目录,设置权限

[root@localhost ~]# mkdir /date/samba/shard -p
[root@localhost ~]# chmod 777 /date/samba/shard/ -R
修改/etc/samba/smb.conf的配置文件
[root@localhost ~]# cat /etc/samba/smb.conf
 See smb.conf.example for a more detailed config file or
read the smb.conf manpage.
 Run 'testparm' to verify the config is correct after
you modified it.
[global]
    workgroup = SAMBA
    security = user
    map to guest = Bad User  //匿名用户 虚拟的
    passdb backend = tdbsam
    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw
[samba-shard]
    comment = This is shard           //说明信息
    path = /date/samba/shard          //共享文件的路径
    browseable = yes                  //共享文件可见
    guest ok =yes                     //所有人均可访问共享
    writable = yes                     //读写权限
    public = yes                      //开启匿名访问

检测配置文件是否修改有误

[[email protected] ~]# testparm 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[samba-shard]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
重启服务
[[email protected] ~]# systemctl restart smb

客户端检测
查看共享目录

[[email protected] ~]# smbclient -L 192.168.100.33 -U 'Bad user' //不用输入密码,直接回车

挂载

[root@localhost ~]#mkdir /cifs //建立挂载点
[root@localhost ~]#mount -t cifs //192.168.100.33/samba-shard /cifs/ -o user="Bad User" //不用输入密码 直接回车

验证检测

[root@localhost ~]#mkdir qinyong //客户端有写入权限
[root@localhost ~]# ls /date/samba/shard/
qinyong systemctl enable smb

搭建匿名用户共享服务器,服务端配置,新建共享目录,设置权限

[root@localhost ~]# mkdir /date/samba/shard -p
[root@localhost ~]# chmod 777 /date/samba/shard/ -R
修改/etc/samba/smb.conf的配置文件
[root@localhost ~]# cat /etc/samba/smb.conf
See smb.conf.example for a more detailed config file or
 read the smb.conf manpage.
Run 'testparm' to verify the config is correct after
 you modified it.
[global]
    workgroup = SAMBA
    security = user
    map to guest = Bad User  //匿名用户 虚拟的
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[samba-shard]
    comment = This is shard           //说明信息
    path = /date/samba/shard          //共享文件的路径
    browseable = yes                  //共享文件可见
    guest ok =yes                     //所有人均可访问共享
    writable = yes                     //读写权限
    public = yes                      //开启匿名访问

检测配置文件是否修改有误

[[email protected] ~]# testparm 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[samba-shard]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

重启服务

[root@localhost ~]# systemctl restart smb

客户端检测,查看共享目录

[[email protected] ~]# smbclient -L 192.168.100.100 -U 'Bad user' //不用输入密码,直接回车
挂载
[[email protected] ~]#mkdir /cifs //建立挂载点
[[email protected] ~]#mount -t cifs //192.168.100.33/samba-shard /cifs/ -o user="Bad User" //不用输入密码 直接回车

检测

[root@localhost ~]#mkdir qinyong //客户端有写入权限
[root@localhost ~]# ls /date/samba/shard/
qinyong yum -y install samba-client //客户端
相关标签: smb服务器搭建