首页 > 其他分享 >配置samba共享,实现/www目录共享

配置samba共享,实现/www目录共享

时间:2023-10-07 15:26:31浏览次数:37  
标签:test1 www samba test2 client 共享 root


#服务器端配置:
[root@samba ~]#yum install -y samba
[root@samba ~]#groupadd -r www
[root@samba ~]#useradd -s /sbin/nologin -G www test1
[root@samba ~]#smbpasswd -a test1
New SMB password:
Retype new SMB password:
Added user test1.
[root@samba ~]#useradd -s /sbin/nologin test2
[root@samba ~]#smbpasswd -a test2
New SMB password:
Retype new SMB password:
Added user test2.
[root@samba ~]#mkdir /www
[root@samba ~]#chgrp www /www
[root@samba ~]#chmod 2775 /www
[root@samba ~]#vim /etc/samba/smb.conf
#加上一下这段配置。设置共享目录为/www,设置www组中用户有写权限
[share]
path = /www
write list = @www

#启动服务
[root@samba ~]#systemctl enable --now smb nmb

#客户端配置
[root@client ~]# yum install -y cifs-utils
#分别用test1,test2用户进行挂载共享目录
[root@client ~]# mkdir /mnt/test1
[root@client ~]# mkdir /mnt/test2
[root@client ~]# mount -o username=test1 //10.0.0.150/share /mnt/test1
Password for test1@//10.0.0.150/share: ******
[root@client ~]# mount -o username=test2 //10.0.0.150/share /mnt/test2
Password for test2@//10.0.0.150/share: ******
[root@client ~]# echo "test1" >> /mnt/test1/test.txt
[root@client ~]# cat /mnt/test1/test.txt
test1
[root@client ~]# touch /mnt/test2/test.txt
touch: cannot touch ‘/mnt/test2/test.txt’: Permission denied
#说明:test1用户在www组,samba服务给了www组写的权限,test2用户不在www组,因此创建文件失败。

#配置自动挂载
[root@client ~]# cat /etc/smb.txt
username=test1
password=123456
[root@client ~]# chmod 600 /etc/smb.txt
[root@client ~]# echo "//10.0.0.150/share /mnt/test1 cifs credentials=/etc/smb.txt 0 0" >> /etc/fstab
#自动挂载测试ok
[root@client ~]# mount -a
[root@client ~]# ll /mnt/test1
total 4
-rwxr-xr-x 1 root root 6 Nov 18 18:40 test.txt

[root@client ~]# yum install -y samba-client
[root@client ~]# smbclient //10.0.0.150/share -U test1%123456
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Thu Nov 18 18:40:54 2021
.. D 0 Thu Nov 18 18:29:35 2021
test.txt A 6 Thu Nov 18 18:40:54 2021

104806400 blocks of size 1024. 98400288 blocks available
smb: \>

标签:test1,www,samba,test2,client,共享,root
From: https://www.cnblogs.com/tanll/p/17746367.html

相关文章

  • python进程之间共享数据
    python进程之间共享数据Value#Value是multiprocessing库提供的对象类​#示例:frommultiprocessingimportProcess,Value​​deftask(num:Value):  #提供锁解决同步问题  withnum.get_lock():    num.value+=1    print(f'process_num={num......
  • windows远程左面与共享文件夹
    目录windows开启远程桌面连接共享文件夹windows开启远程桌面连接参考:https://jingyan.baidu.com/article/b7001fe1a4aac54f7382dd45.html远程共享连接程序:C:\Windows\System32\mstsc.exe注意:关闭防火墙,两台计算机的登录用户必须都要有密码共享文件夹A机器创建共享文件......
  • 国标GB28181视频平台EasyCVR共享融合云平台中AI中台的定义及功能
    AI中台是将深度学习、计算机视觉、知识图谱、自然语言理解等人工智能技术进行模块化,并结合硬件计算能力、算法训练能力、模型部署能力以及基础业务展现能力等功能的集约化平台。同时,AI中台与中台的数据资源密切结合,将这些能力封装成一个完整的中台系统。安防视频监控平台EasyCVR是......
  • 【14.0】中间件、跨域资源共享、后台任务、测试用例
    【一】中间件【1】中间件介绍FastAPI中间件是在处理请求和响应的过程中介入的组件,允许你在请求到达处理函数之前或响应离开处理函数之后执行一些逻辑。中间件在FastAPI中起到非常灵活的作用,可以用于日志记录、身份验证、异常处理等。【2】中间件的工作原理(1)注册中间件......
  • windows&linux共享
    优点:可以使用VS直接编辑linux跨平台代码apt-getinstallsambavim/etc/samba/smb.conf[code]//名称path=/code//路径writeable=yesbrowseable=yesguestok=yespkillsmbdsmbd//启动ps//显示当前终端的进程ps-ef|grepsmbd//|表示管道的输出;grep是过滤mk......
  • Windows共享
    Windows共享1.注意:如果两台主机没有ping通的话,请注意检查防火墙是否关掉。(或者对防火墙进行精细化设置)2.3.4.首先,我们在服务器上创建一个test文件夹。并设置NTFS权限:1.zhangsan对其具有完全控制权限2.zhangsan1对其具有读取和执行权限......
  • Android 基于共享内存跨进程实时传输大量图片
     aidl传输文件有大小1M限制,单次传输不适合传递大数据,可以使用aidl传递共享内存引用ParcelFileDescriptor方式传递图片信息。具体实现如下一、service端1.aidl文件IIpcService.aidl定义,这里主要用到pfd参数interfaceIIpcService{/***Demonstratessomebasictypes......
  • 使用LPD协议来共享打印机
    打开“控制面板”,“程序和功能”,“启动或关闭Windows功能”,下拉找到“打印和文件服务”,勾选“LPD打印服务”和“LPR端口监视器”。确定之后重启电脑,共享主机和其它需要添加共享打印机的都开启功能和重启。一、启动LPD服务二、添加共享打印机第一步:安装好对应型号的打印机的驱......
  • Ubuntu安装Samba(阿里云服务器、samba端口映射)Win10可访问
    1、安装Samba服务sudoapt-getinstallsamba #安装Samba服务器sudoapt-getinstallsmbclient #安装Samba客户端查看samba版本samba-V2、配置需要共享的目录#新建目录,用于共享mkdir/usr/local/volumes#更改权限信息sudochownnobody:nogroup/usr/local......
  • Linux访问Windows共享
    在Linux中创建一个挂载点,这个挂载点将用来挂载Windows共享。可以使用sudomkdir/mnt/windows创建一个名为“windows”的目录作为挂载点。挂载Windows共享,执行命令sudomount-tcifs-ousername=windows_username,password=windows_password//windows_computer_name/sha......