samba共享服务安装

1987年,微软公司和英特尔公司共同制定了SMB(Server Messages Block,服务器消息块)协议,旨在解决局域网内的文件或打印机等资源的共享问题,这也使得在多个主机之间共享文件变得越来越简单。到了1991年,当时还在读大学的Tridgwell为了解决Linux系统与Windows系统之间的文件共享问题,基于SMB协议开发出了SMBServer服务程序。这是一款开源的文件共享软件,经过简单配置就能够实现Linux系统与Windows系统之间的文件共享工作。当时,Tridgwell想把这款软件的名字SMBServer注册成为商标,但却被商标局以SMB是没有意义的字符而拒绝了申请。后来Tridgwell不断翻看词典,突然看到一个拉丁舞蹈的名字—Samba,而且这个热情洋溢的舞蹈名字中又恰好包含了“SMB”,于是Samba服务程序的名字由此诞生(见图12-1)。Samba服务程序现在已经成为在Linux系统与Windows系统之间共享文件的最佳选择。

第12章 使用Samba或NFS实现文件共享。第12章 使用Samba或NFS实现文件共享。

安装samba

yum install -y samba

配置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

        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 = /home/database  #重点修改这里就可以了
        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

默认情况:

security = user

配置完重新启动samba

systemctl restart smb && systemctl enable smb

建立共享目录

[root@localhost ~]# mkdir /home/database
[root@localhost ~]# chown -Rf feiyu:feiyu /home/database

客户端测试:

配置samba用户的数据库密码

[root@Server ~]# smbpasswd -a feiyu   

-a  打开

-d  关闭

测试时关闭防火墙

linux客户端连接:

[root@localhost ~]# smbclient -L 192.168.0.98 -U feiyu

[root@localhost ~]# smbclient \\192.168.0.98/feiyu -U feiyu

windows客户端连接

\\192.168.8.132 ---->输入用户名密码即可访问

总结:默认情况,本地用户可以访问自己的家目录, 但是需要将用户加入到smb数据库中,匿名用户没有可访问的目录.

如果security = share 本地用户无法访问;

security = user 本地用户可以访问, 匿名用户能否访问取决于是否有共享目录允许匿名用户访问。

猜你喜欢

转载自blog.csdn.net/bbwangj/article/details/81186743