samba服务搭建
一:安装samba.service服务
[root@localhost ~]# yum -y install samba
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/4): extras/7/x86_64/primary_db | 249 kB 00:00
(2/4): base/7/x86_64/group_gz | 153 kB 00:00
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:03
updates/7/x86_64/primary_db FAILED
http://mirrors.njupt.edu.cn/centos/7.9.2009/updates/x86_64/repodata/1ef0fd1d33c5486f04c87531f4368d851b5c3bd7d70fd3b9f60507768f96695e-primary.sqlite.bz2: [Errno 14] curl#18 - "transfer closed with 18970007 bytes remaining to read"
Trying other mirror.
(4/4): updates/7/x86_64/primary_db | 19 MB 00:03
Determining fastest mirrors
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:4.10.16-20.el7_9 will be installed
......
Dependencies Resolved
======================================================================
Package Arch Version Repository Size
======================================================================
Installing:
samba x86_64 4.10.16-20.el7_9 updates 720 k
Installing for dependencies:
cups-libs x86_64 1:1.6.3-51.el7 base 359 k
libldb x86_64 1.5.4-2.el7 updates 149 k
libtalloc x86_64 2.1.16-1.el7 base 33 k
libtdb x86_64 1.3.18-1.el7 base 49 k
libtevent x86_64 0.9.39-1.el7 base 41 k
libwbclient x86_64 4.10.16-20.el7_9 updates 117 k
pyldb x86_64 1.5.4-2.el7 updates 49 k
pytalloc x86_64 2.1.16-1.el7 base 18 k
python-tdb x86_64 1.3.18-1.el7 base 20 k
samba-client-libs x86_64 4.10.16-20.el7_9 updates 5.0 M
samba-common noarch 4.10.16-20.el7_9 updates 216 k
samba-common-libs x86_64 4.10.16-20.el7_9 updates 183 k
samba-common-tools x86_64 4.10.16-20.el7_9 updates 467 k
samba-libs x86_64 4.10.16-20.el7_9 updates 271 k
Updating for dependencies:
dbus x86_64 1:1.10.24-15.el7 base 245 k
dbus-libs x86_64 1:1.10.24-15.el7 base 169 k
krb5-libs x86_64 1.15.1-55.el7_9 updates 810 k
Transaction Summary
======================================================================
Install 1 Package (+14 Dependent packages)
Upgrade ( 3 Dependent packages)
Total download size: 8.8 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/base/packages/dbus-libs-1.10.24-15.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for dbus-libs-1.10.24-15.el7.x86_64.rpm is not installed
(1/18): dbus-libs-1.10.24-15.el7.x86_64.rpm | 169 kB 00:00
(2/18): libtalloc-2.1.16-1.el7.x86_64.rpm | 33 kB 00:00
(3/18): libtdb-1.3.18-1.el7.x86_64.rpm | 49 kB 00:00
(4/18): cups-libs-1.6.3-51.el7.x86_64.rpm | 359 kB 00:00
(5/18): libtevent-0.9.39-1.el7.x86_64.rpm | 41 kB 00:00
Public key for libldb-1.5.4-2.el7.x86_64.rpm is not installed
(6/18): libldb-1.5.4-2.el7.x86_64.rpm | 149 kB 00:00
(7/18): krb5-libs-1.15.1-55.el7_9.x86_64.rpm | 810 kB 00:00
(8/18): pytalloc-2.1.16-1.el7.x86_64.rpm | 18 kB 00:00
(9/18): python-tdb-1.3.18-1.el7.x86_64.rpm | 20 kB 00:00
(10/18): libwbclient-4.10.16-20.el7_9.x86_64.rpm | 117 kB 00:00
(11/18): pyldb-1.5.4-2.el7.x86_64.rpm | 49 kB 00:00
(12/18): samba-4.10.16-20.el7_9.x86_64.rpm | 720 kB 00:00
(13/18): samba-common-4.10.16-20.el7_9.noarch.rp | 216 kB 00:00
(14/18): samba-libs-4.10.16-20.el7_9.x86_64.rpm | 271 kB 00:00
(15/18): samba-common-tools-4.10.16-20.el7_9.x86 | 467 kB 00:00
(16/18): samba-common-libs-4.10.16-20.el7_9.x86_ | 183 kB 00:00
(17/18): samba-client-libs-4.10.16-20.el7_9.x86_ | 5.0 MB 00:00
(18/18): dbus-1.10.24-15.el7.x86_64.rpm | 245 kB 00:01
----------------------------------------------------------------------
Total 6.0 MB/s | 8.8 MB 00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libtalloc-2.1.16-1.el7.x86_64 1/21
Installing : libtdb-1.3.18-1.el7.x86_64 2/21
Installing : libtevent-0.9.39-1.el7.x86_64 3/21
Installing : libldb-1.5.4-2.el7.x86_64 4/21
Updating : krb5-libs-1.15.1-55.el7_9.x86_64 5/21
Installing : 1:cups-libs-1.6.3-51.el7.x86_64 6/21
Installing : samba-common-4.10.16-20.el7_9.noarch 7/21
Installing : libwbclient-4.10.16-20.el7_9.x86_64 8/21
Installing : samba-common-libs-4.10.16-20.el7_9.x86_64 9/21
Installing : samba-client-libs-4.10.16-20.el7_9.x86_64 10/21
Updating : 1:dbus-libs-1.10.24-15.el7.x86_64 11/21
Installing : python-tdb-1.3.18-1.el7.x86_64 12/21
Installing : pyldb-1.5.4-2.el7.x86_64 13/21
Installing : pytalloc-2.1.16-1.el7.x86_64 14/21
Installing : samba-libs-4.10.16-20.el7_9.x86_64 15/21
Installing : samba-common-tools-4.10.16-20.el7_9.x86_64 16/21
Installing : samba-4.10.16-20.el7_9.x86_64 17/21
Updating : 1:dbus-1.10.24-15.el7.x86_64 18/21
Cleanup : 1:dbus-1.6.12-13.el7.x86_64 19/21
Cleanup : 1:dbus-libs-1.6.12-13.el7.x86_64 20/21
Cleanup : krb5-libs-1.13.2-10.el7.x86_64 21/21
Verifying : 1:cups-libs-1.6.3-51.el7.x86_64 1/21
Verifying : 1:dbus-1.10.24-15.el7.x86_64 2/21
Verifying : libldb-1.5.4-2.el7.x86_64 3/21
Verifying : libtevent-0.9.39-1.el7.x86_64 4/21
Verifying : libwbclient-4.10.16-20.el7_9.x86_64 5/21
Verifying : samba-libs-4.10.16-20.el7_9.x86_64 6/21
Verifying : samba-common-libs-4.10.16-20.el7_9.x86_64 7/21
Verifying : python-tdb-1.3.18-1.el7.x86_64 8/21
Verifying : pyldb-1.5.4-2.el7.x86_64 9/21
Verifying : samba-common-tools-4.10.16-20.el7_9.x86_64 10/21
Verifying : libtdb-1.3.18-1.el7.x86_64 11/21
Verifying : samba-common-4.10.16-20.el7_9.noarch 12/21
Verifying : krb5-libs-1.15.1-55.el7_9.x86_64 13/21
Verifying : libtalloc-2.1.16-1.el7.x86_64 14/21
Verifying : pytalloc-2.1.16-1.el7.x86_64 15/21
Verifying : 1:dbus-libs-1.10.24-15.el7.x86_64 16/21
Verifying : samba-client-libs-4.10.16-20.el7_9.x86_64 17/21
Verifying : samba-4.10.16-20.el7_9.x86_64 18/21
Verifying : krb5-libs-1.13.2-10.el7.x86_64 19/21
Verifying : 1:dbus-1.6.12-13.el7.x86_64 20/21
Verifying : 1:dbus-libs-1.6.12-13.el7.x86_64 21/21
Installed:
samba.x86_64 0:4.10.16-20.el7_9
Dependency Installed:
cups-libs.x86_64 1:1.6.3-51.el7
libldb.x86_64 0:1.5.4-2.el7
libtalloc.x86_64 0:2.1.16-1.el7
libtdb.x86_64 0:1.3.18-1.el7
libtevent.x86_64 0:0.9.39-1.el7
libwbclient.x86_64 0:4.10.16-20.el7_9
pyldb.x86_64 0:1.5.4-2.el7
pytalloc.x86_64 0:2.1.16-1.el7
python-tdb.x86_64 0:1.3.18-1.el7
samba-client-libs.x86_64 0:4.10.16-20.el7_9
samba-common.noarch 0:4.10.16-20.el7_9
samba-common-libs.x86_64 0:4.10.16-20.el7_9
samba-common-tools.x86_64 0:4.10.16-20.el7_9
samba-libs.x86_64 0:4.10.16-20.el7_9
Dependency Updated:
dbus.x86_64 1:1.10.24-15.el7
dbus-libs.x86_64 1:1.10.24-15.el7
krb5-libs.x86_64 0:1.15.1-55.el7_9
Complete!
二:开启samba服务,设置开机自启动,关闭防火墙自启动
[root@localhost ~]# systemctl start smb.service
[root@localhost ~]# systemctl enable smb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost ~]# init 6
Last login: Thu Feb 23 07:14:17 2023 from 192.168.33.1
三:创建共享/data目录,用户组samba和用户tony,并配置smaba文件共享目录用户tony的密码
[root@localhost ~]# mkdir /data
[root@localhost ~]# groupadd samba
[root@localhost ~]# useradd -g samba tony
[root@localhost ~]# smbpasswd -a tony
New SMB password:
Retype new SMB password:
Added user tony.
四:重启samba服务,修改samba的配置文件
[root@localhost ~]# systemctl restart smb.service
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# chmod 777 /data/
添加以下内容到最后一行:
[data]
comment = data
valid users = @samba
read only = no
path = /data
hosts allow = 192.168.
writeable = yes
write list = tony
[root@localhost ~]# 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.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[data]
comment = data
##共享目录为/data
valid users = @samba
##有效用户为samba
read only = no
##目录权限不为只读
path = /data
##路径为/data
hosts allow = 192.168.
##允许的主机地址网段
writeable = yes
##是否能进行编辑
write list = tony
五:重启服务
systemctl restart smb.service
六:使用windows输入“win+R”打开快捷命令提示框,输入:\IP地址
即可进入到samba的共享目录下,可以通过修改配置文件,对权限进行修改。
版权声明:本文为qq_65100354原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。