Application of Linuxsamba Server

Source: Internet
Author: User
The application of the Linuxsamba server-Linux Enterprise Application-Linux server application information. The following is a detailed description. The system is fedora and only development tools are installed.

1. Installation

Samba server requires three software packages: samba server software package and samba-client.

(Samba client tool), samba-common (common tools and libraries ).
Since I only installed the development tools during the installation of fedora

In a software dependency, you must first install an rpmdb Software Package (rpmdb is a solution for software installation and storage

To install the samba software package.
Insert the third disc, attach it, and cd it to the Fedora/RPMS path.
Ls | grep rpmdb lists rpm packages that currently include rpmdb, that is, the following rpmdb-fedora-2-

0.20040513.i386.rpm
Rpm-ivh rpmdb-fedora-2-0.20040513.i386.rpm/* this software is third in fedora

In the disk Fedora/RPMS */
Rpm-ivh -- aid samba *. rpm/* install the samba package. samba *. rpm is in the first position of fedora.

In the disk Fedora/RPMS, -- aid is used together with the previously installed rpmdb. It is initially installed

Required for samba package Renewal */
Rpm-qa | grep samba/* use rpm to query the files currently installed that contain samba. In-ql

Q = query, a = all */
Rpm-ql samba-3.0.3-5
Rpm-ql samba-client-3.0.3-5
Rpm-ql samba-common-3.0.3-5/* check the content of the samba package.-ql

Q = query, l = list */

2. Several common samba tools

Smbtree displays the list of all shared hosts and directories in the LAN
Smbclient display/login to the shared host/directory in the LAN
Usage: smbclient-L-N win2000/* anonymous login win2000 machine,-N indicates anonymous,-L

List of shared directories */
Smbclient // win2000/share-U username % password/* use username and password

Smb users and passwords are used to log on to a share directory under win2000.

The smb :\> prompt appears. Here we provide two commands in this status: put, get, and unix/linux.

The ftp command below is similar. Note that the put must be followed by two parameters, for example, smb: \> put

/Root/install. log install. log, which specifies not only to upload a local file, but also

Parameters uploaded to another machine. Here, the install. log is

Name */
Smbmount // win2000/share/mnt-o username = username % password /*

Mount the shared directory to the local device. Use umount to cancel mounting */

3. samba Server Configuration

The configuration file of the samba server is smb. conf, located in/etc/samba/smb. conf
You must pay attention to several frequently used parameters, workgroup and security in [global ].
The following shows how to set a share in a samba configuration file.
Vi/etc/samba/smb. conf
Make some modifications in [gobal]
Workgroup = workgroup
Security = share
Then press shift + g (vi usage, that is, to the end of the file) to reach the end of the smb. conf file, the new

Create a share
[Mongodocs]
Comment = share documents/* annotation document type */
Path =/usr/share/doc/* specify the sharing path */
Public = yes/* confirm publishing and sharing */
Save and exit (here we will use the relevant instructions of vi, you can use the relevant vi), and then re-

Start samba service
Service smb restart
Use smbclient-L localhost to test the samba server

4. samba User Account

To add a samba user, you must add a system account before joining the samba account.
Useradd redhat/* Add a redhat user */
Smbpasswd-a redhat/* directly add the smb service password for the redhat account, and the-a parameter is used to add smb

User,-x is used to delete smb users */
The following is an example of setting a valid user for a shared directory:
Add a shared directory to/etc/samba/smb. conf.
[Redhat]
Comment = redhat's files
Path =/var/redhat
Public = no
Valid users = tom @ redhat/* sets the valid user as tom or a user in the redhat Group */
Save and exit. Restart the smb service.
It is necessary to mention the samba user account ing concept here. For account security considerations, to prevent samba

The user uses the samba account to guess the information of the System user. Therefore, a samba user ing occurs, as shown in figure

, Map the preceding tom account to another name, and use other names such as jack and fig.

The logon permission and logon password are the same as those of tom.
To implement account ing, first open the account ing service in/etc/samba/smb. conf.

Simple: Find the username map =/etc/samba/smbusers line and remove the line above it.

Yes (in linux; indicates disabled; # indicates annotation. Note that it is different from # in freebsd). However

Modify/etc/samba/smbusers
Vi/etc/samba/smbusers
Add a line in it, tom = jack rhood.
Save and quit, restart the smb service, and then you can log on to the redhat shared directory with jack and fig.

And the logon password is exactly the same as that of tom.

5. samba server permission settings

We use the example of a samba configuration file to illustrate this problem.
[Redhat]
Comment = redhat's files
Path =/var/redhat
Public = no
Valid = tom @ redhat/* valid user */
Write list = tom @ redhat/* users with write permissions */
Create mask = 0660/* permission for creating files. Here is 660, that is, rw-rw ---- permission, that is

The owner and the same group have the readable and writable permissions */
Directory mask = 0660/* permission on the directory, which is also 660 permission */
[Add permission knowledge: r = read, = write in gossip, 2 x = Execution in gossip, and 8

The hexadecimal code is 1. In rw-rw ---- above, the nine characters are divided into three parts, and the first three characters are the file owner.

(Rw-, readable and writable). The three characters in the middle are the permissions of the same group (rw-, readable and writable ),

The following is the permissions of others (---, unreadable, unwritable, and unexecutable), changed to gossip, r + w +-

= 2 + 1 + 0 = 6, so it forms a format such as mask = 0660. For permissions such as 770,775

You can think about it on your own]

6. Example

Scenario: tom and jack are members of the sales group, and fig and joeys are members of the technical department.

Create a samba server. each user has his/her own samba account, which has two groups: sales group and tech group.

Members of the Group cannot access each other. No shell is assigned to the members.
After the analysis, you need to do the following: 1. Create a samba account for all users; 2. Create a sales account and a tech account.

Group, and assign permissions to the group. 3. Do not assign shell to all members. 4. Share their files.
Operation:
Groupadd sales/* Create group sales */
Groupadd tech
Useradd-g sales-s/bin/false tom/* Add tom to the sales group (-g sales ).

Configure shell Permission (-s/bin/false )*/
Useradd-g sales-s/bin/false jack
Smbpasswd-a tom
Smbpasswd-a jack
Useradd-g tech-s/bin/false fig
Useradd-g tech-s/bin/false joeys
Smbpasswd-a fig
Smbpasswd-a joeys
Mkdir/home/sales/home/tech/* respectively create a directory for sales and tech */
Chgrp sales/home/sales/* change the owner of the Directory */
Chgrp tech/home/tech
Chmod 770/home/sales/* change the directory permission to rwxrwx ---*/
Chmod 770/hoem/tech
Chmod g + s/home/sales/* adds the process owner to the directory to ensure that the directory is always

The remote location belongs to the owner */
Chmod g + s/home/tech
Ls-ld/home/sales/home/tech/* view directory permissions */
Edit the samba configuration file to share the directory.
Vi/etc/samba/smb. conf
Set the security level in [global] to user
Security = share
Then shift + g to the end of the configuration file to set the directory sharing
[Sales]
Comment = sales

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.