本文共 4633 字,大约阅读时间需要 15 分钟。
实验题目:
实验一:搭建匿名用户共享服务器 实验二:搭建用户认证共享服务器 实验环境 首先要测试网络的连通性,服务器端和客户机端要互联互通主机名称 | 操作系统 | ip地址 |
---|---|---|
Samba服务器 | RHEL 7 | 192.168.168.138 |
Samba客户机 | RHEL 7 | 192.168.168.137 |
实验前环境搭建:
1:在服务端安装samb服务,关闭防火墙,并开启[root@wuliay ~]# yum -y install samba-*[root@wuliay ~]#systemctl stop firewalld.service
2:在客户端安装samba-client
[root@client shanyao]#yum -y install samba-client
*实验一:搭建匿名用户共享服务器
在服务端进行的操作:
第一步:编辑samba服务下/etc/samba/smb.conf配置文件:[global] workgroup = SAMBA security = user passdb backend = tdbsam map to guest = bad user #添加匿名用户 printing = cups printcap name = cups load printers = yes cups options = raw [shanyao] #共享文件名 comment = shanyao path = /opt/shanyao 共享文件路径 browseable = Yes guest ok = yes writable = yes public =yes
第三步:创建共享目录,并设置目录为所有用户可读写和执行的权限;
[root@wuliay ~]# mkdir /opt/shanyao[root@wuliay ~]# chmod 777 /opt/shanyao[root@wuliay ~]# ll /opt/total 0drwxr-xr-x. 2 root root 6 Sep 12 04:54 hellodrwxrwxrwx. 2 root root 6 Sep 12 21:08 shanyao
第四部启动smb服务器:
root@wuliay ~]systemctl start smb
*在客户端进行的操作:
第一步:查看samba服务器有哪些共享资源:[root@client opt]# smbclient -L 192.168.168.138 -U 'bad user'Enter SAMBA\bad user's password: OS=[Windows 6.1] Server=[Samba 4.6.2] Sharename Type Comment --------- ---- ------- shanyao Disk shanyao IPC$ IPC IPC Service (Samba 4.6.2)OS=[Windows 6.1] Server=[Samba 4.6.2] Server Comment --------- ------- Workgroup Master --------- -------
第二步:将samba服务上的共享资源shanyao挂载到客户机本地:```[root@client opt]# mount -t cifs //192.168.168.138/shanyao /opt/shanyao/ -o username='bad user` ```第三步:查看一下挂载的进程:
root@client opt]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 38G 1.5G 37G 4% /devtmpfs 903M 0 903M 0% /devtmpfs 912M 0 912M 0% /dev/shmtmpfs 912M 8.7M 903M 1% /runtmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda1 297M 123M 174M 42% /boottmpfs 183M 0 183M 0% /run/user/0//192.168.168.138/shanyao 37G 1.1G 36G 3% /opt/shanyao
第四步:在客户端共享目录里面创建文件:
[root@client opt]# cd /opt/shanyao[root@client shanyao]# touch wanglao[root@client shanyao]# mkdir jiaduo[root@client shanyao]# lsjiaduo wanglao
*在服务端进行查看:
[root@wuliay ~]# cd /opt/shanyao[root@wuliay shanyao]# ls[root@wuliay shanyao]# cd /opt/shanyao[root@wuliay shanyao]# lsjiaduo wanglao
*实验二:搭建用户共享认证共享服务器
在服务端进行操作:
第一步:
创建共享文件,并赋予777的权限:[root@wuliay opt]# mkdir fs[root@wuliay fs]# chmod 777 /opt/fs
第二步:创建主机端用户su,设密码为123
[root@wuliay opt]# useradd su #创建用户su[root@wuliay opt]# smbpasswd -a suNew SMB password:Retype new SMB password:Added user su.
第三步:映射su用户为lo用户,
[root@wuliay opt]# chown -R su.su /opt/fs[root@wuliay opt]# echo 'su = lo' > /etc/samba/do[root@wuliay opt]# cat /etc/samba/do su = lo
第四步:编辑/etc/samba/smb.conf这个文件
[global] workgroup = SAMBA security = user username map =/etc/samba/do #添加这一行 passdb backend = tdbsam map to guest = bad user printing = cups printcap name = cups load printers = yes cups options = raw [wuse] comment = wuse path = /opt/fs browseable = Yes guest ok = yes writable = yes public =yes
第五步:重启smb服务```[root@wuliay fs]# systemctl restart smb
客户端进行操作: 第一步: 在客户机上查看samba服务器有哪些共享资源
[root@client ~]# smbclient -L 192.168.168.138 -U lo
Enter SAMBA\lo's password: Anonymous login successfulOS=[Windows 6.1] Server=[Samba 4.6.2]arename Type Commentshanyao Disk shanyao
IPC$ IPC IPC Service (Samba 4.6.2)wuse Disk wuseonymous login successful OS=[Windows 6.1] Server=[Samba 4.6.2]Server Comment
Workgroup Master
第二步:将Samba服务器的共享资源/opt/heihei挂载到客户机
[root@client opt]# mount -t cifs //192.168.168.138/wuse /opt/fs/ -o username=lo,password=123
第三步:查看挂载进程:
[root@client opt]# df -h
Filesystem Size Used Avail Use% Mounted on/dev/sda3 38G 1.5G 37G 4% /devtmpfs 903M 0 903M 0% /devtmpfs 912M 0 912M 0% /dev/shmtmpfs 912M 8.7M 903M 1% /runtmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda1 297M 123M 174M 42% /boottmpfs 183M 0 183M 0% /run/user/0//192.168.168.138/shanyao 37G 1.1G 36G 3% /opt/shanyao//192.168.168.138/wuse 37G 1.1G 36G 3% /opt/fs第三步:在客户端共享目录里面创建新文件:
[root@client fs]# touch 12
[root@client fs]# ls 12[root@client fs]# echo “successful” < /opt/fs/12 successful*在服务端进行验证:
[root@wuliay fs]# cat /opt/fs/12
successful转载于:https://blog.51cto.com/13945839/2178070