如何配置samba服务
1)、samba简介
samba是在Linux和UNIX系统上面实现SMB协议的免费软件,由服务器及其客户端程序构成。
samba是一种局域网通信协议,他可以为同一局域网中的计算机提供文件以及打印等资源共享
Samba的端口号
TCP | UDP |
---|---|
139 | 137 |
455 | 138 |
Samba的进程
进程 | 对应 |
---|---|
nmbd | netbios |
smbd | cifs协议 |
winbinbd | win AD活动目录 |
关于Samba的用户的操作
smbpasswd [选项] 用户名
常见选项:
选项 | 作用 |
---|---|
-a | 添加samba用户 |
-e | 禁用samba用户 |
-x | 删除samba用户 |
-d | 禁用samba用户 |
实操:
#添加samba用户
[root@lzj ~]# smbpasswd -a user2
#后面选项以此类推
samba的配置文件
[root@lzj ~]# ls /etc/samba/
lmhosts smb.conf smb.conf.example
[root@lzj ~]#
2)实操
服务端
前提
1、关闭防火墙
[root@lzj ~]# systemctl stop firewalld
2、下载samba的软件包
[root@lzj ~]# yum install -y samba
3、修改samba的配置文件
[root@lzj ~]# 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.
。。。。。。
#此处为修改内容--末行
[lzj] #名称
path = /sam #共享目录,前提为/sam目录已经创建
browseable = yes #是否可游览
writable=yes #是否可写
write list=yes #可写
[root@lzj ~]#
3、开启服务
[root@lzj ~]# systemctl start nmb smb
[root@lzj ~]#
4、共享文件授权
#文件允许samba用户读写执行,user为samba用户
[root@lzj ~]# setfacl -m u:user:rwx /sam/
5、添加samba用户
5、检查
[root@lzj ~]# testparm
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Registered MSG_REQ_POOL_USAGE
Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[lzj]"
Loaded services file OK. #OK说明成功
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
客户端
1、下载
[root@lzj ~]# yum install -y samba-client
2、创建挂载目录
[user1@lzj ~]$ mkdir public
3、检查是否有共享
#如下说明成功
[user1@lzj ~]$ smbclient //192.168.135.145/lzj -U user2
Unable to initialize messaging context
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it
Enter WORKGROUP\user2's password:
Try "help" to get a list of possible commands.
smb: \>
4、挂载
[user1@lzj ~]$ mount -t cifs //192.168.135.145/lzj public/ -o username=user2,password=123