SAMBA

Samba is a service to share files with others. That support UTF-8 code, so, We can share files with Chinese names.

Install

We always use samba in lan, with others, so, that service don’t need to be a HA Service.

There are two method to install samba: one is yum, the other is compile. Because that service don’t need to be an HA Service, we can use yum to install it.


yum install samba

Let me see the directory tree with Samba:


[root@localhost samba]# tree

.

├── lmhosts

├── smb.conf

└── smb.conf.example



0 directories, 3 files

We can see, There have a smb.conf, That is samba’s configuration file,and there have that file’s example.

Config Samba

Edit smb.conf:


[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 = /var/tmp

        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

Do not edit the original file.

There are some important key:

  • security: That is the method to login samba. We can use share and user.

Create a share directory

Write a model in smb.conf. Like


[test]

    comment=

    path = /test

    public = no

    browseable = yes

    valid user = test1,test

    write list = test1

    create mask = 0644

    directory mask = 0755

Comment key: Information of this model.

path: Directory path

public: This directory is a public directory ?

browseable: Dose that directory can browse able by each user.

valid user: Users allowed to access

write list: Users allowed to wirte

mask: Set upload files mask

OK,There is a samba’s rule.

I will add two user named test and test1,and i will add that user to smbdb.


useradd test -s /sbin/nologin

useradd test1 -s /sbon/nologin

smbpasswd -a test

smbpasswd -a test1

Then ,restart samba service.

Verification

Install a tool named samba-client,and input command:


bash# smbclient -L \\192.168.89.164 -U test





	Sharename       Type      Comment

	---------       ----      -------

	print$          Disk      Printer Drivers

	test            Disk      

	IPC$            IPC       IPC Service (Samba 4.9.1)

Reconnecting with SMB1 for workgroup listing.



	Server               Comment

	---------            -------



	Workgroup            Master

	---------            -------

If command line return this information ,It means that the configuration is successful.

To use

Mount to windows:

Input url \\192.168.89.164in This PC’s url box. The system requires me to enter user and password.

At first time ,I’m going to use test.

Copy a file to that directory, and the OS tells us that it cannot be written in that directory with insufficient permissions.

Then going to use test1 ,and try again.

We found that read and write are normal in this time.

Virtual user

Samba’s virtual user like user’s alias.

Create a samba user list file:


test1 = t1 t2 t3

Add a key to smb.conf


[global]

        security = user

        username map = /etc/samba/smbusers

Restart samba and login try again.

This time ,we use user t1 and the password same as test1.

If you login ,that mean is your virtual account is configured correctly.

Observe the samba’s file, we can find ,that this file is the same as file for test1’s.

So, I always call that is samba user’s alias.

That’s all.

Thanks.

Reference:

Samba服务(匿名用户访问、本地用户访问、虚拟用户访问)

SAMBA服务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值