一、简介
Samba服务功能强大,这与通信是基于SMB协议有大的有关系。SMB协议不仅能够提供目录和共享打印机,还支持认证和权限设置等功能。在早期。SMB运行于NBT协议上,使用UDP协议的137、138及TCP协议的139端口,但随着后期开发,它可以直接运行于TCP/IP协议上,没有额外的NBT层,使用TCP协议的445端口。
通过Samba服务,Windows用户可以通过[网上邻居]窗口查看到Linux服务器中的共享的资源,同时Linux用户也能够查看到服务器上的共享资源。
二、配置
服务器端配置
安装samba服务
[root@server ~]# yum -y install samba
临时关闭selinux[root@server~]# setenforce 0
关闭防火墙[root@server ~]# systemctl stop firewalld
[root@server ~]# systemctl stop iptables
添加共享目录及修改目录权限 [root@server~]# mkdir /common
[root@server ~]# chmod 777 /common
[root@server ~]# echo "hello the word " > /common/smb.txt
编辑samba主配置文件[root@server ~]# vim /etc/samba/smb.conf
添加下面内容
[common]
commonent=Common share
path = /common
browseable = yes
guest ok = no
writable = yes
创建samba用户[root@server~]# useradd -s /sbin/nologin smbuser
[root@server ~]# smbpasswd -a smbuser
重启下samba服务[root@server~]# systemctl restart smb
客户端配置
windows环境访问
按win+R快捷键开启运行对话,输入\\IP(IP为samba服务器的IP地址)
Linux环境访问安装samba客户端
[root@client ~]# yum -y install samba-client
访问samba[root@client ~]# smbclient -U smbuser //172.25.0.254/common