What is samba in linux

青灯夜游
Release: 2022-04-14 17:23:58
Original
5710 people have browsed it

In Linux, samba is an open source software based on the SMB protocol. It is a software that allows the Linux system to apply the Microsoft network communication protocol. The samba software can be used for file sharing between Windows and Linux, and for resource sharing between Linux and Linux.

What is samba in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

1. Overview of Samba

1. Introduction to samba

Samba is available on Linux and UNIX A free software that implements the SMB protocol on the system, consisting of server and client programs.

SMB is a communication protocol for sharing files and printers on a local area network. It provides sharing services for files, printers and other resources between different computers in the local area network.

The SMB protocol is a C/S type protocol through which clients can access shared file systems, printers and other resources on the server.

samba is a software that allows Linux systems to apply Microsoft network communication protocols. The biggest function of samba is that it can be used for direct file sharing and print sharing between Linux and windows systems. samba can be used for both windows. File sharing with Linux can also be used for resource sharing between Linux and Linux.

Samba service composition

1) SMB is the core startup service of samba. It is mainly responsible for establishing a dialogue between the Linux samba server and the samba client and verifying user identity. It also provides access to the file and printing system. Only when the SMB service is started can file sharing be realized and monitor the 139 TCP port.

2) The NMB service is responsible for resolution. It is similar to the function implemented by DNS. NMB can match the workgroup name shared by the Linux system with its IP. If the NMB service is not started, it can only be accessed through IP. Access shared files and listen on UDP ports 137 and 138.

Install samba service

yum -y install samba
Copy after login

Check the installation status

rpm -qa | grep samba
Copy after login

2. samba listening port

##139 | 445137 | 138
TCPUDP
    The service corresponding to the tcp port is the smbd service, which is used to provide shared access to files and printing resources in the server
  • The service corresponding to the udp port is the nmbd service, which is used to provide resolution based on NetBIOS host names

3. samba process

Processcorresponds to##nmbdsmbdwinbindd ldap
corresponds to netbios
corresponds to cifs protocol
corresponds to Windows AD active directory

4. samba user

##AccountPasswordare all system users/etc/passwdThe Samba service has its own password file set through the command
//smbpasswd 命令:
    -a Sys_User     //添加系统用户为 samba 用户并为其设置密码
    -d              //禁用用户帐号
    -e              //启用用户帐号
    -x              //删除用户帐号
 
 
[root@localhost ~]# yum -y install samba-*
[root@localhost ~]# useradd tom
[root@localhost ~]# smbpasswd -a tom
New SMB password:
Retype new SMB password:
Added user tom.
Copy after login
smbpasswd -a USERNAME
5. samba security level

The Samba server has three security levels, They are user, server, domain

##security levelfunctionuserLocal-based authenticationUser identity is authenticated by another designated serverAuthentication by domain controllerPrevious samba versions supported four security levels They are share, user, server, domain
server
domain
  • share is used to set up anonymous access, but the current version no longer supports share, but anonymous access can still be achieved. The configuration method has changed
  • 6. samba configuration file

/etc/samba/smb.conf (main configuration File)

samba three major componentsfunction[ global]Global configuration, the settings here are valid for the entire samba serverHost directory sharing settings, here Used to set the default share for Linux users, corresponding to the user's home directory. When a user accesses a shared directory with the same name as his or her user name on the server, it will be automatically mapped to the user's home directory after passing verification Printer sharing settings
[homes]
[printers]

7. 常用配置文件参数

参数作用
workgroup表示设置工作组名称
server string表示描述 samba 服务器
security表示设置安全级别,其值可为 share、user、server、domain
passdb backend表示设置共享帐户文件的类型,其值可为 tdbsam(tdb数据库文件)、ldapsam(LDAP目录认证)、smbpasswd(兼容旧版本 samba 密码文件)
comment表示设置对应共享目录的注释,说明信息,即文件共享名
browseable表示设置共享是否可见
writable表示设置目录是否可写
path表示共享目录的路径
guest ok表示设置是否所有人均可访问共享目录
public表示设置是否允许匿名用户访问
write list表示设置允许写的用户和组,组要用 @ 表示,例如 write list = root,@root
valid users设置可以访问的用户和组,例如 valid users = root,@root
hosts deny设置拒绝哪台主机访问,例如 hosts deny = 192.168.10.100
hosts allow设置允许哪台主机访问,例如 hosts allow = 192.168.10.200
printable表示设置是否为打印机
#测试配置文件是否有语法错误,以及显示最终生效的配置。使用 testparm 命令
[root@localhost ~]# testparm
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$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
......
Copy after login

二、搭建匿名用户共享服务器(Linux - Linux)

1. 环境准备

IP主机系统
192.168.10.20serverCentOS7
192.168.10.30clientCentOS7
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
yum -y install ntp && ntpdate ntp.aliyun.com

//server
hostnamectl set-hostname server
su
//client
hostnamectl set-hostname client
su
Copy after login

2. 服务端

yum -y install samba-* &> /dev/null
systemctl start smb && systemctl enable smb

#添加全局配置
vim /etc/samba/smb.conf
......
[global]
        workgroup = SAMBA
        security = user
        map to guest = Bad User
......

#创建共享文件夹
mkdir -p /opt/yc
chmod 777 /opt/yc/
ll /opt/

#配置共享
cat >> /etc/samba/smb.conf << EOF
[yc]
comment = yc
path = /opt/yc
browseable = yes
guest ok = yes
writable = yes
public = yes
EOF

#测试配置文件是否有误
testparm

#重启服务
systemctl restart smb
Copy after login

3. 客户端

yum -y install samba-* &> /dev/null
systemctl start smb && systemctl enable smb

#客户端验证
smbclient -L 192.168.10.20 -U &#39;Bad User&#39;	#123456
mkdir -p /opt/smb
mount -t cifs //192.168.10.20/yc /opt/smb/ -o username=&#39;Bad User&#39;
df -h

#在客户端上创建共享目录,文件
cd /opt/smb/ && touch test && mkdir yanchuang
ls
Copy after login

4. 服务端上验证

[root@server ~]#cd /opt/yc
[root@server /opt/yc]#ls
test  yanchuang
Copy after login

三、Windows 访问共享文件

同网段 windows 虚拟机访问

What is samba in linux
What is samba in linux
What is samba in linux

不同网段 windows 虚拟机访问

  • 需要认证

What is samba in linux

相关推荐:《Linux视频教程

The above is the detailed content of What is samba in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template