centos8.4安装samba

2021年10月24日14:42:05 评论 33

关闭防火墙

  1. [root@localhost ~]# systemctl stop firewalld.service
  2. [root@localhost ~]# systemctl disable firewalld.service
  3. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  4. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

关闭selinux

  1. [root@localhost ~]# cat /etc/selinux/config
  2.  
  3. # This file controls the state of SELinux on the system.
  4. # SELINUX= can take one of these three values:
  5. # enforcing - SELinux security policy is enforced.
  6. # permissive - SELinux prints warnings instead of enforcing.
  7. # disabled - No SELinux policy is loaded.
  8. # SELINUX=enforcing
  9. SELINUX=disabled
  10. # SELINUXTYPE= can take one of three two values:
  11. # targeted - Targeted processes are protected,
  12. # minimum - Modification of targeted policy. Only selected processes are protected.
  13. # mls - Multi Level Security protection.
  14. SELINUXTYPE=targeted

安装

  1. [root@localhost ]# yum install samba
  2.  
  3. #查看
  4. [root@localhost ]# rpm -qa | grep samba
  5. samba-common-libs-4.8.3-4.el7.x86_64
  6. samba-libs-4.8.3-4.el7.x86_64
  7. samba-common-tools-4.8.3-4.el7.x86_64
  8. samba-common-4.8.3-4.el7.noarch
  9. samba-client-libs-4.8.3-4.el7.x86_64
  10. samba-4.8.3-4.el7.x86_64
  11. samba-client-4.8.3-4.el7.x86_64

安装包说明

  1. samba-common-3.5.10-125.el6.x86_64 //主要提供samba服务器的设置文件与设置文件语法检验程序testparm
  2. samba-client-3.5.10-125.el6.x86_64 //客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集
  3. samba-swat-3.5.10-125.el6.x86_64 //基于https协议的samba服务器web配置界面
  4. samba-3.5.10-125.el6.x86_64 //服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项

配置服务

安装后会生成/etc/samba目录,

  1. #======================= Global Settings =====================================
  2.  
  3. [global]
  4.  
  5. # ----------------------- Network Related Options -------------------------
  6. #
  7. # workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
  8. #
  9. # server string is the equivalent of the NT Description field
  10. #
  11. # netbios name can be used to specify a server name not tied to the hostname
  12.  
  13. workgroup = WORKGROUP
  14. server string = Liuyunsheng Samba Server Version %v
  15. netbios name = Liuyunsheng-Samba
  16.  
  17. # --------------------------- Logging Options -----------------------------
  18. #
  19. # Log File let you specify where to put logs and how to split them up.
  20.  
  21. log file = /var/log/samba/log.%m
  22. # ----------------------- Standalone Server Options ------------------------
  23. #
  24. # Scurity can be set to user, share(deprecated) or server(deprecated)
  25.  
  26. security = user
  27. map to guest = Bad User
  28.  
  29. #============================ Share Definitions ==============================
  30.  
  31. [public]
  32. comment = Public Stuff
  33. path = /home/test
  34. writeable = yes
  35. public = yes
  36.  
  37. [Centos]
  38.  
  39. path = /opt/cen
  40. valid users = Centos
  41. writeable = yes
  42. public = yes
  43. browseable = No
  44. create mask = 0777
  45. directory mask = 0777

启动服务和查看服务

  1. # 启动smb服务
  2. [root@localhost samba]# systemctl start smb
  3. [root@localhost samba]# systemctl status smb
  4. smb.service - Samba SMB Daemon
  5. Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
  6. Active: active (running) since Thu 2019-04-25 14:44:24 CST; 3s ago
  7. Docs: man:smbd(8)
  8. man:samba(7)
  9. man:smb.conf(5)
  10. Main PID: 22111 (smbd)
  11. Status: "smbd: ready to serve connections..."
  12. Memory: 8.3M
  13. CGroup: /system.slice/smb.service
  14. ├─22111 /usr/sbin/smbd --foreground --no-process-group
  15. ├─22115 /usr/sbin/smbd --foreground --no-process-group
  16. ├─22116 /usr/sbin/smbd --foreground --no-process-group
  17. └─22117 /usr/sbin/smbd --foreground --no-process-group
  18.  
  19. Apr 25 14:44:24 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
  20. Apr 25 14:44:24 localhost.localdomain smbd[22111]: [2019/04/25 14:44:24.814732, 0] ../lib/util/become_daemon.c:138(daemon_ready)
  21. Apr 25 14:44:24 localhost.localdomain smbd[22111]: daemon_ready: STATUS=daemon 'smbd' finished starting up and ready to serve connections
  22. Apr 25 14:44:24 localhost.localdomain systemd[1]: Started Samba SMB Daemon.

添加账户(添加的账户必须linux已经创建的)

直接添加用户test会导致失败
  1. [root@localhost share]# smbpasswd -a test
  2. Unknown parameter encountered: "     map to guest"
  3. Ignoring unknown parameter "     map to guest"
  4. New SMB password:
  5. Retype new SMB password:
  6. Failed to add entry for user test.
创建linux账户
  1. [root@localhost share]# groupadd test -g 6000
  2. [root@localhost share]# useradd test -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
  3. useradd: warning: the home directory already exists.
  4. Not copying any file from skel directory into it.
创建samba用户
  1. [root@localhost share]# smbpasswd -a test
  2. Unknown parameter encountered: "     map to guest"
  3. Ignoring unknown parameter "     map to guest"
  4. New SMB password:
  5. Retype new SMB password:
  6. Added user test.
删除samba用户
  1. [root@localhost samba]# smbpasswd -x test
  2. Deleted user test.

客户端访问共享目录

  1. windows输入\.6.6.192
  2. 然后输入设置的用户名和密码就可以了,并且可以将连接的文件夹映射为网络驱动器,这样就可以直接操作了

设置开机启动的方法:

在终端命令行中输入:

  1. chkconfig smb on
weinxin
博主微信
这是我的微信扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: