Samba authentication process and permissions

Source: Internet
Author: User
Samba authentication process and permissions-Linux Enterprise Application-Linux server application information. For details, refer to the following section. I. Summary
Samba provides file services to the local area network through two programs: smbd and nmbd. Among them, nmbd is the Netbios name resolution program. Generally, only one nmbd process is run in the system. smbd is a program that actually provides file services. Generally, each customer sends a request, the Samba server starts a smbd process.
Nmbd and smbd share a configuration file: smb. conf. In Debian Etch, this file is located in the/etc/samba directory. Samba will automatically repeat the content of this file every 60 s. Therefore, each time you modify the file and save the disk, you can wait 60 s for the new configuration options to take effect, or you can manually restart the process using the/etc/init. d/samba restart script. Before using a new process, you can use testparm to check whether the File Syntax is correct.

Ii. Authentication and permissions
The Samba authentication process is divided into two steps.
1. Samba first compares the user name and password provided by the client with the records in the local database. If yes, the client is given the permission to access shared resources. This process seems to have to come up with the right key first in a room.
2. But entering the room does not mean you can use everything in the room at will. Samba determines whether the client can access a specific file or use other resources (such as printers) according to certain rules ). The rules here are defined in the smb. conf file, and more importantly, based on the Linux File Permission System. The smbd process will access the file with the permissions of the verified user (this means that the user name passed to the Sambe verification in the previous step must have the corresponding permissions in the/etc/passwd file of the server. project ).

Iii. authentication process
1. samba has four methods to authenticate client identities: share-level, user-level, and server-level) domain-level ). The last three methods are essentially similar. The difference is that the verification takes place differently. In user-level mode, this process occurs on the Samba server, in server-level mode, On the other server, and in domain-level mode, the PDC or BDC performs authentication.
2. share-level and user-level are the two most common authentication methods. user-level is the default value of Samba configuration.
The differences between the two modes on the client are as follows: in share-level mode, the client does not need to enter the user name, as long as the password is entered; in user-level mode, the client must enter both the user name and password.
On the server side, there is little difference between the two modes: Samba uses a combination of user names and passwords for authentication. At user-level, Samba checks the user name and password passed by the client with the records in the local database. In share-level, Samba uses smb because the client does not pass the user name. the username provided by a resource segment in the conf file and the default username set in the Samba compilation process are combined with the password, and then compared with the records in the local database, as long as a combination can pass verification, the client can access the shared resources with the permissions of the user corresponding to the corresponding user name. If none of the combinations have been verified, access from the client is denied.
In share-level, a special case is that if a shared resource is set
Guest OK = yes
Guest only = yes
Guest account = the account of a user
When the client is connected, Samba automatically grants the client the permissions of the specified guest account to access shared resources. In this case, the client does not even need to provide a password.

Iv. Password Transmission
Both share-level and user-level can be found in smb. the conf file specifies how the Samba server interprets the password sent from the received client: the password can be in plaintext or encrypted format. The client sends the password in that way, which is determined by the operating system of the client. For example, Windows 95 can only send the password in plain text, and Windows XP sends the password in encrypted form by default, however, you can change it in the Registry to send the plaintext password. Therefore, if there are multiple clients of different versions, you need to maintain both the plaintext Password Database and the encrypted password database on the Samba server.
Use encrypt passwords = yes/no in the smb. conf file to configure how Samba interprets the received password.
When Samba is configured to interpret the passed password in plain text, it uses/etc/passwd as the basis for verification. When Samba is configured to interpret the passed password in encrypted form, it uses smbpasswd as the basis for verification (In Debian Etch, this file is located in the/etc/samba directory by default, but it can be found in smb. in the conf file .)
(My idea: the password stored in the/etc/passwd or/etc/shadow file by Linux users is also encrypted, but this encryption algorithm is not supported by the Windows client. In this way, the client cannot encrypt the password locally using the same algorithm and then send it over the network. Instead, it can only pass the password to the Samba server in plaintext format, the Samba server converts the file according to the algorithm supported by/etc/passwd and compares it with the records in/etc/passwd.
The danger of plaintext transmission of passwords is obvious, so in Windows, the password is encrypted first and then sent to the server. However, the problem is that the algorithm used for Windows encryption is different from the algorithm used for/etc/passwd, therefore, Samba cannot directly compare the received plaintext password with/etc/passwd. In addition, Windows uses a one-way algorithm. This means that the encrypted password received by Samba from the client cannot be restored from the plaintext. After further conversion, it is compared with/etc/passwd. In a word, the/etc/passwd or/etc/shadow file cannot be used as the basis for verification when the password is encrypted .)
Because the smbpasswd file is independent from the/etc/passwd file, the user password for Samba shared resources can be different from the logon password. However, in the smbpasswd file, each user must have a corresponding record in the/etc/passwd file, because after verification, samba grants the client the corresponding permissions of this user to access the corresponding resources.

V. Permissions
After the client passes identity authentication, you can use various resources provided by Samba. Smb. conf uses two options: browsable and writable to control whether users can browse and write a resource.
At the same time, the read and write operations on the client are controlled by the Linux permission system. For example, the owner, group, and permission of a file are as follows:
Rwxr-x --- user_a group_1 somefile
The user names and components of three users are:
Username group name
User_a group_1
User_ B group_1
User_c group_2
① After the client connects to and passes verification with user_a, it can read and write the file;
② After the client connects with user_ B and passes verification, it can only read and write the file;
③ After the client connects with user_c and passes verification, the client cannot read or write the file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.