3. 配置samba共享,实现www目录共享

3. 配置samba共享,实现www目录共享

实验环境:两台CentOS8

 

服务器配置

1.安装服务器包

[root@centos8:~]#yum -y install samba

[root@centos8:~]#systemctl enable --now smb

 

2.创建相关共享目录,创建登录账号(samba的虚拟用户必须是操作系统账号转化而来,)

创建登录账号

[root@centos8:~]#useradd smb1

[root@centos8:~]#useradd smb2

 

将系统账号转化为samba账号

[root@centos8:~]#smbpasswd -a smb1

[root@centos8:~]#smbpasswd -a smb2

 

查看当前的账号

[root@centos8:~]#pdbedit -L

smb1:1001:

smb2:1002:

#smb账号存放在/var/lib/samba/private/passdb.tdb数据库文件中

 

3.修改配置文件,设置共享目录和写权限

[root@centos8:~]#mkdir /www

[root@centos8:~]#touch /www/haha.txt

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

[www]

path=/www

writable=yes

 

文件系统添加写权限

[root@centos8:~]#chmod 777 /www/   

[root@centos8:~]#systemctl restart smb

 

 

 

客户端配置

安装相关软件包,创建挂载目录

[root@client ~]# yum install samba-client cifs-utils -y

[root@client /]# mkdir haha{1,2}

[root@client ~]# smbclient -L 10.0.0.8 -U smb1%123456

Sharename       Type      Comment

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

print$          Disk      Printer Drivers

www             Disk      

IPC$            IPC       IPC Service (Samba 4.14.5)

smb1            Disk      Home Directories

SMB1 disabled -- no workgroup available

 

[root@client ~]# smbclient -L 10.0.0.8 -U smb2%123456

Sharename       Type      Comment

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

print$          Disk      Printer Drivers

www             Disk      

IPC$            IPC       IPC Service (Samba 4.14.5)

smb2            Disk      Home Directories

SMB1 disabled -- no workgroup available

 

客户端临时挂载

[root@client /]# mount -o username=smb1 //10.0.0.8/www /haha1

Password for smb1@//10.0.0.8/www:  ******

[root@client /]# mount -o username=smb2 //10.0.0.8/www /haha2

Password for smb2@//10.0.0.8/www:  ******

[root@client /]# df | grep haha

//10.0.0.8/www 104806400  5626100  99180300   6% /haha1

//10.0.0.8/www 104806400  5626100  99180300   6% /haha2

 

客户端永久挂载

[root@client /]#vim /etc/fstab

//10.0.0.8/www /haha1 cifs username=smb1,password=123456 0 0

//10.0.0.8/www /haha2 cifs username=smb2,password=123456 0 0

[root@client /]#mount -a

 

[root@client /]# cd haha1

[root@client haha1]# ls

haha.txt

 

posted @   惊起千层浪  阅读(630)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示