CIFS(Samba)配置与检测

本文详细介绍了如何在Linux系统中安装Samba服务,包括设置主机名、配置文件、共享目录权限、启动服务、创建Samba用户及密码,并探讨了匿名登录的设置。
摘要由CSDN通过智能技术生成

安装 Samba 服务

[root@samba ~]# hostnamectl set-hostname samba
[root@samba ~]# yum install -y samba

配置 samba 的配置文件 /etc/samba/smb.conf

[root@samba ~]# vi /etc/samba/smb.conf
[share]
        comment = samba share 
        path = /opt/share  #共享目录
        browseable = yes   #操作权限
        public = yes       #访问权限
        writable =yes      #对文件的操作权限

创建目录并赋予权限

[root@samba ~]# mkdir /opt/share
[root@samba ~]# chmod 777 /opt/share

启动 samba 服务

[root@samba ~]# systemctl start smb
[root@samba ~]# systemctl start nmb

查看端口启动情况 (必须安装了 net-tools 软件包)

[root@samba ~]# yum install -y net-tools

[root@samba ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address     Foreign Address     State     PID/Program name 
tcp        0      0 0.0.0.0:139       0.0.0.0:*           LISTEN    4460/smbd 
tcp        0      0 0.0.0.0:22        0.0.0.0:*           LISTEN    1114/sshd
tcp        0      0 127.0.0.1:25      0.0.0.0:*           LISTEN    1360/master
tcp        0      0 0.0.0.0:445       0.0.0.0:*           LISTEN    4460/smbd
tcp6       0      0 :::139            :::*                LISTEN    4460/smbd 
tcp6       0      0 :::22             :::*                LISTEN    1114/sshd
tcp6       0      0 ::1:25            :::*                LISTEN    1360/master
tcp6       0      0 :::445            :::*                LISTEN    4460/smbd

创建 Samba 用户 —— root用户并设置密码

[root@samba ~]# smbpasswd -a root  #用户必须存在
New SMB password:
Retype new SMB password:
Added user root.

创建 Samba 用户 ——— 普通用户并设置密码

[root@samba ~]# smbpasswd -a AH
New SMB password:
Retype new SMB password:
Added user AH.

重启 Samba 服务

[root@samba ~]# service smb restart
Redirecting to /bin/systemctl restart smb.service

拓展

现在登录用户为AH现在换成root有两种方法

方法一    用命令

再次登录就行

匿名登录

[root@samba ~]# vi /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
        map to guest =bad user  #允许匿名登陆

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

匿名登陆会直接进入无法选择登录用户

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值