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

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

1.实验架构

2.服务器构建

1.安装服务器包
[root@centos8:~]#
yum -y install samba
[root@centos8:~]#
systemctl enable --now smb   #端口号为445和139

2.创建相关共享目录,创建登录账号(samba的虚拟用户必须是操作系统账号转化而来,)
[root@centos8:~]#
useradd smb1
[root@centos8:~]#将系统账号转化为samba账号
smbpasswd -a smb1
New SMB password:
Retype new SMB password:
Added user smb1.
[root@centos8:~]#查看当前的账号
pdbedit -L
smb1:1001:
[root@centos8:~]#
useradd smb2
[root@centos8:~]#
smbpasswd -a smb2
New SMB password:
Retype new SMB password:
Added user 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/a.txt
[root@centos8:~]#
vim /etc/samba/smb.conf
[www]
path=/www    #[share1]只是个名字,具体位置由path指定
writable=yes            #samba共享服务开启写权限
[root@centos8:~]#
chmod 777 /www/   #文件系统添加写权限。
[root@centos8:~]#
systemctl restart smb

3.客户端测试

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

	Sharename       Type      Comment
	---------       ----      -------
	print$          Disk      Printer Drivers
	share1          Disk      
	IPC$            IPC       IPC Service (Samba 4.14.5)
	smb1            Disk      Home Directories
Reconnecting with SMB1 for workgroup listing.
smbXcli_negprot_smb1_done: No compatible protocol selected by server.
protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE
Unable to connect with SMB1 -- no workgroup available
[root@centos7:~]#
smbclient  //10.0.0.8/share1 -U smb1%123456
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Fri Jun 17 19:34:16 2022
  ..                                  D        0  Fri Jun 17 19:33:35 2022
  a.txt                               N        0  Fri Jun 17 19:34:16 2022

		52403200 blocks of size 1024. 52004800 blocks available
smb: \> get a.txt        #下载
getting file \a.txt of size 0 as a.txt (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec)
smb: \> !ls
anaconda-ks.cfg  a.txt
smb: \> put anaconda-ks.cfg       #上传
putting file anaconda-ks.cfg as \anaconda-ks.cfg (220.3 kb/s) (average 220.3 kb/s)
smb: \> ls
  .                                   D        0  Fri Jun 17 19:50:11 2022
  ..                                  D        0  Fri Jun 17 19:33:35 2022
  a.txt                               N        0  Fri Jun 17 19:34:16 2022
  anaconda-ks.cfg                     A     1579  Fri Jun 17 19:50:11 2022

		52403200 blocks of size 1024. 52004796 blocks available

4.客户端挂载

1.安装软件包
[root@centos7:~]#
yum -y install cifs-utils
2.永久挂载
[root@centos7:~]#
vim /etc/fstab 
//10.0.0.8/www        /mnt/www             cifs    username=smb1,password=123456 0 0
[root@centos7:~]#
mkdir /mnt/www
[root@centos7:~]#
mount -a
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值