Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Samba

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install Samba, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

For linux and windows sharing and peaceful coexistence, we can use Samba software

Samba is a set of free open source software that can implement windows domain controller, file service, printing service and so on on linux or other unix-like operating systems.

Samba implements the core network protocol used in windows system: SMB (Server Message Block).

Samba can provide the following features:

Active Directory Services (Active Directory Server, ADS)

Primary domain controller (Primary Domain Controller, PDC)

Shared directory

Shared printer

Samba is a high-performance service software, which only needs lower hardware to achieve the same performance of windows server.

First, install Samba

Sudo apt-get install samba

After the installation is complete, visit (my linux server ip:192.168.1.66) on windwos:

Enter\\ 192.168.1.66 as shown:

You can see from the title bar that you can access it, but there are no shared resources in it.

II. Configuration of Samba

The configuration file for Samba is / etc/samba/smb.conf, which uses the same syntax as the .ini file for windows.

Note: when modifying the configuration exercise, please back up the original configuration file

The simplest configuration

[global] security= share[linux _ share] path=/home/linux/sharepublic=yes

This configuration is divided into two segments:

* * paragraph: global

The second paragraph: linux_share. This is a self-defined name. When accessed from windows, you can see the name of the shared folder.

Security=share, which indicates that the security level is share, so that the user does not need to be authenticated by a password.

Path defines the path to the shared folder

Public=yes says it's open to everyone to access.

When the configuration is complete, check the syntax of the configuration file: use the testparm command

As shown in the figure:

Restart Samba takes effect

Sudo / etc/init.d/smbd restart

Now you can see the shared folder we created through windows access.

III. Security certification of Samba

Samba provides security certification levels, which are divided into four levels:

Share: no need to enter user name and password user: need to enter user name and password, Samba authenticates users server: another Samba server or Windows server is responsible for authentication domain: designate a windows server to authenticate users

Where user is the default security authentication level for Samba, that is, in the / etc/samba/smb.conf configuration file, change the security line to security=user, so the user must enter a user name and password before browsing the shared content.

Now upgrade the security level to user

Sudo vim / etc/samba/ smb.confm [global] security= username [Linux _ share] path=/home/linux/sharevalid users=cdyemail # specifies valid users, multiple accessible public=no # public access separated by commas as No

Restart the samba service: sudo / etc/init.d/smbd restart

Access through windows as shown below:

Now you need a password, but you cannot pass authentication by entering the user name and password of linux. If you want Samba to pass authentication, you need the following points:

(1) create users in ubuntu system

(2) create the user in Samba

(3) create the same user in windows (same password as Samba user)

1. Create a user in Ubuntu

If you want to share a resource with a new user, you must first add the user to Ubuntu with the adduser command. Such as:

We are going to share a resource with a user called cdyemail. The first thing we need to do is to create this user in the Ubuntu system.

Sudo useradd cdyemail

In this way, there is a cdyemail user in the system.

2. Create a user in Samba

Users in Ubuntu systems and Samba users are two different things. To share resources with users in a system, you must add that user to Samba.

Add method:

Sudo smbpasswd-a cdyemail#smbpasswd is a command,-an is add user, and cdyemail is user name

In this way, the authentication information of cdyemail is written to Samba. Restart Samba takes effect

After adding the user and password, you can now access it through this user name and password in windows.

3. Create the same user in windows

In the windows client, we need to create exactly the same user name and password as in samba in order to pass the authentication of Samba. When we open the Samba shared resource on the windows client, Samba will automatically transfer the user information in the windows environment to the server for authentication, so if the login windows user and Samba user name are the same (the password is also the same), there is no need to enter the password and can automatically pass the authentication.

I passed the test, which is very powerful!

4. Samba user password modification

If the password is changed, both windows and Samba should be changed synchronously. The method of modification in Samba is as follows:

Sudo smbpasswd cdyemail # cdyemail is the user name to be modified

If the windows is not modified, enter the user name and password modified by Samba manually, and log out after windows modification (re-login)

III. Control of sharing rights

Directory We only need to access the contents of the file, but we do not have permission to modify the file, nor can we add new files to the shared directory.

1. Add file write permission

[global] security= user [Linux _ share] path=/home/linux/sharevalid users=cdyemailwriteable=yes # add a sentence to indicate that you have write permission to public=no

Restart the samba service sudo / etc/init.d/smbd restart, after which you can write the file, but require that the directory on the server itself have this permission. I tested successfully with rwx permissions.

Test for server directory permissions:

Because I share the share directory and use root to create it, by default, I don't have permission to write even if writeable is turned on, because there is a problem with the permissions of the server directory itself.

(1) modify the user's ownership first

Sudo chown cdyemail:cdyemail

(2) only cdyemail users have the right to access this directory

Sudo chmod upright RWX GmbH RWX share

(3) access, test and write files

The test was successful and the cdyemail user has permission to write.

* not finished *

Since we now have to share data under the command line, record it here first, and then record other functions when we have time.

Access the server's shared resources:

The server is configured as follows, a share that requires user authentication, a share that can be accessed by the public.

[global] security= user[share _ resource] path=/home/linux/sharevalid users=shareuserwriteable=yespublic= no[public] path=/home/linux/publicwriteable=yespublic=yes

The client accesses as follows:

Installation: smbclient, smbfs

Smbclient can view and download resources. Here, you can mount a remote shared directory with mount.

Sudo mount-t smbfs-o username=shareuser,passwd=* / / 192.168.1.66/share_resource / mnt/data

# smbfs is a file system type

# share_resource is the share name defined in samba and mounted to the / mnt/data directory

*************************

The above is all the contents of the article "how to install Samba". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report