SAMBA

作者: Tess鱼丸 | 来源:发表于2022-11-20 15:49 被阅读0次
    [root@localhost ~]# 
    [root@localhost ~]# ping www.baidu.com
    PING www.a.shifen.com (180.101.49.13) 56(84) bytes of data.
    64 bytes from 180.101.49.13 (180.101.49.13): icmp_seq=1 ttl=49 time=8.63 ms
    
    64 bytes from 180.101.49.13 (180.101.49.13): icmp_seq=2 ttl=49 time=8.78 ms
    ^C
    --- www.a.shifen.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 999ms
    rtt min/avg/max/mdev = 8.638/8.711/8.785/0.118 ms
    [root@localhost ~]# 
    [root@localhost ~]# yum -y install samba samba-client
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: ftp.sjtu.edu.cn
     * extras: ftp.sjtu.edu.cn
     * updates: ftp.sjtu.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package samba.x86_64 0:4.10.16-20.el7_9 will be installed
    --> Processing Dependency: samba-libs = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: samba-common-tools = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: samba-common-libs = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: samba-common = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: samba-common = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: samba-client-libs = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libwbclient = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libwbclient = 4.10.16-20.el7_9 for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libxattr-tdb-samba4.so(SAMBA_4.10.16)(64bit) for package: samba-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libxattr-tdb-samba4.so()(64bit) for package: samba-4.10.16-20.el7_9.x86_64
    ---> Package samba-client.x86_64 0:4.10.16-5.el7 will be updated
    ---> Package samba-client.x86_64 0:4.10.16-20.el7_9 will be an update
    --> Processing Dependency: libsmbclient = 4.10.16-20.el7_9 for package: samba-client-4.10.16-20.el7_9.x86_64
    --> Running transaction check
    ---> Package libsmbclient.x86_64 0:4.10.16-5.el7 will be updated
    ---> Package libsmbclient.x86_64 0:4.10.16-20.el7_9 will be an update
    ---> Package libwbclient.x86_64 0:4.10.16-5.el7 will be updated
    ---> Package libwbclient.x86_64 0:4.10.16-20.el7_9 will be an update
    ---> Package samba-client-libs.x86_64 0:4.10.16-5.el7 will be updated
    ---> Package samba-client-libs.x86_64 0:4.10.16-20.el7_9 will be an update
    ---> Package samba-common.noarch 0:4.10.16-5.el7 will be updated
    ---> Package samba-common.noarch 0:4.10.16-20.el7_9 will be an update
    ---> Package samba-common-libs.x86_64 0:4.10.16-5.el7 will be updated
    ---> Package samba-common-libs.x86_64 0:4.10.16-20.el7_9 will be an update
    ---> Package samba-common-tools.x86_64 0:4.10.16-20.el7_9 will be installed
    ---> Package samba-libs.x86_64 0:4.10.16-20.el7_9 will be installed
    --> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.1.9)(64bit) for package: samba-libs-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.1.6)(64bit) for package: samba-libs-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.0.6)(64bit) for package: samba-libs-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libpytalloc-util.so.2()(64bit) for package: samba-libs-4.10.16-20.el7_9.x86_64
    --> Processing Dependency: libpyldb-util.so.1()(64bit) for package: samba-libs-4.10.16-20.el7_9.x86_64
    --> Running transaction check
    ---> Package pyldb.x86_64 0:1.5.4-2.el7 will be installed
    --> Processing Dependency: libldb(x86-64) = 1.5.4-2.el7 for package: pyldb-1.5.4-2.el7.x86_64
    --> Processing Dependency: python-tdb(x86-64) >= 1.3.18 for package: pyldb-1.5.4-2.el7.x86_64
    ---> Package pytalloc.x86_64 0:2.1.16-1.el7 will be installed
    --> Running transaction check
    ---> Package libldb.x86_64 0:1.5.4-1.el7 will be updated
    ---> Package libldb.x86_64 0:1.5.4-2.el7 will be an update
    ---> Package python-tdb.x86_64 0:1.3.18-1.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package                 Arch        Version                 Repository    Size
    ================================================================================
    Installing:
     samba                   x86_64      4.10.16-20.el7_9        updates      720 k
    Updating:
     samba-client            x86_64      4.10.16-20.el7_9        updates      647 k
    Installing for dependencies:
     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-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:
     libldb                  x86_64      1.5.4-2.el7             updates      149 k
     libsmbclient            x86_64      4.10.16-20.el7_9        updates      146 k
     libwbclient             x86_64      4.10.16-20.el7_9        updates      117 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
    
    Transaction Summary
    ================================================================================
    Install  1 Package (+5 Dependent packages)
    Upgrade  1 Package (+6 Dependent packages)
    
    Total size: 7.9 M
    Total download size: 1.5 M
    Downloading packages:
    No Presto metadata available for base
    No Presto metadata available for updates
    warning: /var/cache/yum/x86_64/7/base/packages/pytalloc-2.1.16-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Public key for pytalloc-2.1.16-1.el7.x86_64.rpm is not installed
    (1/6): pytalloc-2.1.16-1.el7.x86_64.rpm                                             |  18 kB  00:00:05     
    (2/6): python-tdb-1.3.18-1.el7.x86_64.rpm                                           |  20 kB  00:00:05     
    Public key for pyldb-1.5.4-2.el7.x86_64.rpm is not installed
    (3/6): pyldb-1.5.4-2.el7.x86_64.rpm                                                 |  49 kB  00:00:05     
    (4/6): samba-libs-4.10.16-20.el7_9.x86_64.rpm                                       | 271 kB  00:00:00     
    (5/6): samba-common-tools-4.10.16-20.el7_9.x86_64.rpm                               | 467 kB  00:00:05     
    (6/6): samba-4.10.16-20.el7_9.x86_64.rpm                                            | 720 kB  00:00:06     
    -----------------------------------------------------------------------------------------------------------
    Total                                                                      252 kB/s | 1.5 MB  00:00:06     
    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-9.2009.0.el7.centos.x86_64 (@anaconda)
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Updating   : libldb-1.5.4-2.el7.x86_64                                                              1/20 
      Updating   : samba-common-4.10.16-20.el7_9.noarch                                                   2/20 
      Updating   : libwbclient-4.10.16-20.el7_9.x86_64                                                    3/20 
      Updating   : samba-common-libs-4.10.16-20.el7_9.x86_64                                              4/20 
      Updating   : samba-client-libs-4.10.16-20.el7_9.x86_64                                              5/20 
      Updating   : libsmbclient-4.10.16-20.el7_9.x86_64                                                   6/20 
      Installing : python-tdb-1.3.18-1.el7.x86_64                                                         7/20 
      Installing : pyldb-1.5.4-2.el7.x86_64                                                               8/20 
      Installing : pytalloc-2.1.16-1.el7.x86_64                                                           9/20 
      Installing : samba-libs-4.10.16-20.el7_9.x86_64                                                    10/20 
      Installing : samba-common-tools-4.10.16-20.el7_9.x86_64                                            11/20 
      Installing : samba-4.10.16-20.el7_9.x86_64                                                         12/20 
      Updating   : samba-client-4.10.16-20.el7_9.x86_64                                                  13/20 
      Cleanup    : samba-client-4.10.16-5.el7.x86_64                                                     14/20 
      Cleanup    : libsmbclient-4.10.16-5.el7.x86_64                                                     15/20 
      Cleanup    : libwbclient-4.10.16-5.el7.x86_64                                                      16/20 
      Cleanup    : samba-client-libs-4.10.16-5.el7.x86_64                                                17/20 
      Cleanup    : samba-common-libs-4.10.16-5.el7.x86_64                                                18/20 
      Cleanup    : samba-common-4.10.16-5.el7.noarch                                                     19/20 
      Cleanup    : libldb-1.5.4-1.el7.x86_64                                                             20/20 
      Verifying  : libsmbclient-4.10.16-20.el7_9.x86_64                                                   1/20 
      Verifying  : pyldb-1.5.4-2.el7.x86_64                                                               2/20 
      Verifying  : libldb-1.5.4-2.el7.x86_64                                                              3/20 
      Verifying  : libwbclient-4.10.16-20.el7_9.x86_64                                                    4/20 
      Verifying  : samba-libs-4.10.16-20.el7_9.x86_64                                                     5/20 
      Verifying  : samba-common-libs-4.10.16-20.el7_9.x86_64                                              6/20 
      Verifying  : samba-client-4.10.16-20.el7_9.x86_64                                                   7/20 
      Verifying  : samba-common-tools-4.10.16-20.el7_9.x86_64                                             8/20 
      Verifying  : samba-common-4.10.16-20.el7_9.noarch                                                   9/20 
      Verifying  : pytalloc-2.1.16-1.el7.x86_64                                                          10/20 
      Verifying  : python-tdb-1.3.18-1.el7.x86_64                                                        11/20 
      Verifying  : samba-client-libs-4.10.16-20.el7_9.x86_64                                             12/20 
      Verifying  : samba-4.10.16-20.el7_9.x86_64                                                         13/20 
      Verifying  : samba-client-libs-4.10.16-5.el7.x86_64                                                14/20 
      Verifying  : libwbclient-4.10.16-5.el7.x86_64                                                      15/20 
      Verifying  : libldb-1.5.4-1.el7.x86_64                                                             16/20 
      Verifying  : libsmbclient-4.10.16-5.el7.x86_64                                                     17/20 
      Verifying  : samba-common-4.10.16-5.el7.noarch                                                     18/20 
      Verifying  : samba-client-4.10.16-5.el7.x86_64                                                     19/20 
      Verifying  : samba-common-libs-4.10.16-5.el7.x86_64                                                20/20 
    
    Installed:
      samba.x86_64 0:4.10.16-20.el7_9                                                                          
    
    Dependency Installed:
      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-common-tools.x86_64 0:4.10.16-20.el7_9            
      samba-libs.x86_64 0:4.10.16-20.el7_9            
    
    Updated:
      samba-client.x86_64 0:4.10.16-20.el7_9                                                                   
    
    Dependency Updated:
      libldb.x86_64 0:1.5.4-2.el7                       libsmbclient.x86_64 0:4.10.16-20.el7_9                
      libwbclient.x86_64 0:4.10.16-20.el7_9             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           
    
    Complete!
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# rpm -a samba
    RPM version 4.11.3
    
    [root@localhost ~]# systemctl status smb
    ● smb.service - Samba SMB Daemon
       Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
       Active: inactive (dead)
         Docs: man:smbd(8)
               man:samba(7)
               man:smb.conf(5)
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# systemctl start smb
    [root@localhost ~]# 
    [root@localhost ~]# systemctl status smb
    ● smb.service - Samba SMB Daemon
       Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
       Active: active (running) since Sun 2022-11-20 22:30:04 PST; 2s ago
         Docs: man:smbd(8)
               man:samba(7)
               man:smb.conf(5)
     Main PID: 9759 (smbd)
       Status: "smbd: ready to serve connections..."
        Tasks: 4
       CGroup: /system.slice/smb.service
               ├─9759 /usr/sbin/smbd --foreground --no-process-group
               ├─9765 /usr/sbin/smbd --foreground --no-process-group
               ├─9766 /usr/sbin/smbd --foreground --no-process-group
               └─9767 /usr/sbin/smbd --foreground --no-process-group
    
    Nov 20 22:30:04 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
    Nov 20 22:30:04 localhost.localdomain smbd[9759]: [2022/11/20 22:30:04.607601,  0] ../../lib/util/bec...dy)
    Nov 20 22:30:04 localhost.localdomain smbd[9759]:   daemon_ready: daemon 'smbd' finished starting up ...ons
    Nov 20 22:30:04 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@localhost ~]# 
    

    在/var/share/创建这三个文件夹

    [root@localhost ~]# cd /var/share/
    [root@localhost share]# ls -al
    total 4
    drwxr-xr-x.  2 root root    6 Nov 20 22:08 devel
    drwxr-xr-x.  2 root root    6 Nov 20 22:08 public
    drwxr-xr-x.  2 root root    6 Nov 20 22:08 training
    
    [root@localhost ~]# yum -y tree
    Loaded plugins: fastestmirror, langpacks
    No such command: tree. Please use /bin/yum --help
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# yum -y install tree
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: ftp.sjtu.edu.cn
     * extras: ftp.sjtu.edu.cn
     * updates: ftp.sjtu.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ===========================================================================================================
     Package               Arch                    Version                         Repository             Size
    ===========================================================================================================
    Installing:
     tree                  x86_64                  1.6.0-10.el7                    base                   46 k
    
    Transaction Summary
    ===========================================================================================================
    Install  1 Package
    
    Total download size: 46 k
    Installed size: 87 k
    Downloading packages:
    tree-1.6.0-10.el7.x86_64.rpm                                                        |  46 kB  00:00:05     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : tree-1.6.0-10.el7.x86_64                                                                1/1 
      Verifying  : tree-1.6.0-10.el7.x86_64                                                                1/1 
    
    Installed:
      tree.x86_64 0:1.6.0-10.el7                                                                               
    
    Complete!
    [root@localhost ~]# 
    
    [root@localhost share]# tree /var/share/
    /var/share/
    ├── devel
    ├── public
    └── training
    
    3 directories, 0 files
    [root@localhost share]# 
    [root@localhost share]# 
    

    创建用户和分配到用户组

    [rootepcs01~]#groupadd jsb
    [rootepcs01~]#groupadd kfb
    [rootepcs01~]#useradd -G jsb js1
    [rootepcs01~]#useradd -G jsb js2
    [rootepcs01~]#useradd -G kfb kf1
    [rootepcs01~]#useradd -G kfb kf2
    [rootepcs01~]#groups js1
    jsi : js1 jsb
    [root0pcsoi-]agroups js2
    js2 :js2jsb
    [rootepcsoi~]groups kf1
    kfi : kf1 kfb
    [rootepcs01 -]#groups kf2
    kf2 : kf2 kfb
    

    将刚创建的系统用户账号添加至Samba账号数据库,并设置Samba账号密码(建议和系统账号密码不同)

    [root@localhost share]# pdbedit -L
    [root@localhost share]# smbpasswd -a js1
    New SMB password:
    Retype new SMB password:
    Added user js1.
    [root@localhost share]# pdbedit -L
    js1:1017:
    [root@localhost share]# smbpasswd -a root
    New SMB password:
    Retype new SMB password:
    Added user root.
    [root@localhost share]# 
    [root@localhost share]# pdbedit -L
    js1:1017:
    root:0:root
    [root@localhost share]# 
    

    编辑samba配置文件

    [root@localhost share]# cp /etc/samba/smb.conf smb.bak
    
    [root@localhost share]# vim /etc/samba/smb.conf
    

    在结尾添加以下代码

    重启samba服务

    [root@localhost share]# systemctl restart smb
    [root@localhost share]# 
    [root@localhost share]# systemctl status smb
    ● smb.service - Samba SMB Daemon
       Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
       Active: active (running) since Sun 2022-11-20 22:55:20 PST; 8s ago
         Docs: man:smbd(8)
               man:samba(7)
               man:smb.conf(5)
     Main PID: 10200 (smbd)
       Status: "smbd: ready to serve connections..."
        Tasks: 4
       CGroup: /system.slice/smb.service
               ├─10200 /usr/sbin/smbd --foreground --no-process-group
               ├─10205 /usr/sbin/smbd --foreground --no-process-group
               ├─10206 /usr/sbin/smbd --foreground --no-process-group
               └─10207 /usr/sbin/smbd --foreground --no-process-group
    
    Nov 20 22:55:20 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
    Nov 20 22:55:20 localhost.localdomain smbd[10200]: [2022/11/20 22:55:20.535219,  0] ../../lib/util/be...dy)
    Nov 20 22:55:20 localhost.localdomain smbd[10200]:   daemon_ready: daemon 'smbd' finished starting up...ons
    Nov 20 22:55:20 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@localhost share]# 
    
    

    要关闭防火墙##要关闭防火墙

    要关闭防火墙##要关闭防火墙

    要关闭防火墙##要关闭防火墙

    systemctl stop firewalld.service命令,进行关闭防火墙

    \192.168.1.100

    账号js1 密码js1

    换其他用户登录

    清除所有额网络连接

    C:\Users\Administrator>net use * /del

    C:\Users\Administrator>netsh winsock reset
    成功地重置 Winsock 目录。
    你必须重新启动计算机才能完成重置。
    
    C:\Users\Administrator>net use
    会记录新的网络连接。
    
    状态       本地        远程                      网络
    -------------------------------------------------------------------------------
    OK                     \\192.168.1.100\IPC$      Microsoft Windows Network
    命令成功完成。
    
    C:\Users\Administrator>net use * /del
    你有以下的远程连接:       \\192.168.1.100\IPC$
    继续运行会取消连接。
    
    你想继续此操作吗? (Y/N) [N]: y
    命令成功完成。
    
    C:\Users\Administrator>
    

    相关文章

      网友评论

          本文标题:SAMBA

          本文链接:https://www.haomeiwen.com/subject/rblwxdtx.html