centos7 安装samba服务

samba-安装

1. samba-安装

  • 安装sabma服务

    [root@node02 ~]# yum install samba samba-client samba-swat -y
    
  • 启动服务

    [root@node02 ~]# systemctl enable smb
    [root@node02 ~]# systemctl enable nmb
    [root@node02 ~]# systemctl start smb
    [root@node02 ~]# systemctl start nmb
    

2. 安装samba使用密码用户连接

  • 创建部门用户

    [root@node02 ~]# useradd web
    
  • 创建用户密码

    [root@node02 ~]# smbpasswd -a web
    New SMB password:   
    Retype new SMB password:
    Added user web.
    
    # 注释: 这里密码我设置的web@963852#@!  根据自己情况配置密码
    
  • 创建需要共享的挂载目录

    [root@node02 ~]# mkdir -p /smb/web
    [root@node02 ~]# mkdir -p /sma/public
    [root@node02 ~]# chmod 777 /smb/web/
    [root@node02 ~]# chmod 777 /sma/public/
    
  • 配置samba配置文件

    [root@node02 ~]# 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
    
    # 新添加web共享存储配置
    [WEB]          
            comment = WEB
            path = /smb/web
            public = yes
            valid users = web   # 用该部门的用户才能有权限
            security = share
            guest ok = yes
            writeable = yes
    # 公共文件夹,该目录所有有密码的用户均有权限
    [Public]
            comment = Public
            path = /sma/public
            public = yes
            writeable = yes
    
  • 重启服务

    [root@node02 ~]# systemctl restart smb
    [root@node02 ~]# systemctl restart nmb
    
  • 连接服务测试
    image
    image

    输入用户和密码就可以,访问了

3. 安装samba使用无密码连接

  • 配置sma.conf文件

    若要设置无密码登录,可如下设置

    [root@node02 ~]# vim /etc/samba/smb.conf
    [root@node02 ~]# 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 = root
            security = user              
            map to guest = Bad User         
            #旧版本security = share 即可无密码,新版本security = user且 map to guest = Bad User 才行
            
    # 公共文件夹,该目录所有有密码的用户均有权限
    [Public]
            comment = Public
            path = /sma/public
            public = yes
            writeable = yes
    
  • 重启服务就行

    [root@node02 ~]# systemctl restart smb
    [root@node02 ~]# systemctl restart nmb
    
posted @ 2022-02-24 10:03  七月流星雨  阅读(836)  评论(0编辑  收藏  举报