Linux study notes - Samba uses articles (transfer)

xiaoxiao2021-03-06  49

Linux study notes - Samba used articles 2001-04-06 · · Illiad ·· Yesky 1 Preface: I started to install half a month ago, learn Redhat Linux7.0. As a linux newbie, it is inevitable to meet some problems. By flipping through books, view BBS, our own exploration practice, also solves some problems. Thinking of your own lessons can be used for others, so boldly, you can be used as a study notes, and I have to help friends who have just come into contact with Linux. Since my ability is limited, I have inevitable insufficiency in my notes, and I will also ask the high fingers. 1. Introduction to Samba NetBIOS is an API designed to facilitate development based on local area network-based resource sharing applications. After that, NetBIOS-based NetBeui protocols and NBT (NetBIOS over TCP / IP) protocols are produced. The NBT protocol further develops into SMB and CIFS protocols. Windows LAN default is the NetBeui protocol, and the Samba package is the CIFS protocol. The result is that the machine with the Samba package can communicate with the machine of the Windows network, so that there is no NetBeui protocol, Linux machinery Samba helps with Windows Network Share Resources. Second, Samba's installation Redhat Linux7.0 is installed in the default installation mode. You can use the "rpm -q samba" command to see if Samba is installed and installed. No, you can manually install from the RPM file of Samba from the installation CD. Third, Samba's start-up uses "ps -aux | grep smb" to see if the Samba service is running, whether the default is. Start it with the command "/etc/init.d/smb start; or" LinuxConf "sets the Samba to start when the system is started. For the specific step, run "LinuxConf", click "Control Service Activity", the displayed screen is as shown in the figure, click "SMB" in the "SEVICE Control" list, set the start to "Automatic", "Run Level" is "5".

4. After accessing the Windows client SMB startup, it is not used as any setting you can have access to the machine running Windows. Now there are two machines, running Linux and Windows98, and host names are redhat and LILY, respectively. Directory on LILY "

Download ", with printers"

HP ", the directory is set to" completely accesses ", the password is" ABC ".

1. Access the shared directory on LILY.

The first step is to view the shared resources of the Lily this machine. "

SMBCLIENT -L / / LILY, when prompted, then list the resources available on LILY.

The second step, "

Mkdir / MNT / Download ","

Create a directory under / mnt.

third step,"

Mount -t smbfs -o username = abc, password = abc // LILY / DOWNLOAD / MNT / DOWNLOAD ", hang the shared directory on LIL to Redhat"

/ MNT / DOWNLOAD "Next, you can access the shared directory like using the local hard drive. You can also edit"

/etc/rc.d/rc.local, put "

Mount -t smbfs -o usrname = abc, password = abc // lily / download / mnt / down "Add to the end of the file, so that the system starts, the shared directory is also hung up.

2, use the printer on lily.

Click the Gnome icon on the taskbar, click System, click "

Control panel "." in "

In the Control Panel window, click the printer icon, select "

SMB / Window 95/98 / NT Printer ", as shown.

Then appear window, as shown.

among them"

Hostname of Printer Server "should fill in the host name, here is"

Lily ";"

Printer name "The printer name displayed" SMBCLIENT -L // Lily "is" HP ";" Input Filter "is the model of the printer, as shown

Can be replaced with similar models, such as "

Lily "The printer is HP Deskjet1120c, here is selected with 550C / 560C / 6XXC. These three items must be set. You can then test the printer.

5. Let Windows machine access Linux

Two ways:

1, hand-editing "

/etc/smb.conf file;

2, use graphical interface settings

SMB.CONF. Here is the latter.

edit"

/etc/xinetd.d/swat ", change"

Disable = yes "is"

Disable = no ","

Only_From = localhost "is"

ONLY_FROM = 10.0.0.39 "" Description: The IP address is the network card address of my machine. If you don't change it, use "localhost: 901" to enter the SWAT management interface. You will prompt you: "

A NetWork Ettor Occured While Netsape Was Receiving Data. (NetWork Error: Broken Pipe) Try Connecting Again. "

Enter "10.0.0.39:901" in the browser, enter swat, as shown

The first step, set "

",", as long as the change "

Security "type"

Share ","

"Workgroup" is a group name that appears in network neighbors. "

NetBIOS Name "is the name of the unit in this group, not set, use host name. As shown.

The second step, set "

", as shown

Building a new shared name first, then ""

Choose Share "button next to the button, select this shared name. Set"

"as"

/ home / download ","

Guest OK "is"

Yes ","

Writable "is"

Yes ", don't forget to click"

"Commits" accepts new settings, as shown.

Open the network neighbor on LILY to see there is "

MYGROUP ", there is a" "

Redhat "computer, shared directory is"

Download ".

At this point, a simple two-way share is established. Of course, Samba's function is far less, more complex features, interested friends can see all kinds of information.

Refer to:

Http://www.5ilinux.com/blog/archives/000007.html

With the popularity and popularization of Linux, the documents under Linux share the primary issue of users' concerns. In fact, almost all Linux issuings offer a good tool Samba to easily implement file sharing.

Samba is an application based on the SMB protocol, and the current version is 2.3.x. Samba's function is very powerful, but ease of use is also extremely poor. The reason is that its configuration file is too large and not easy to understand, and novice and cord of hands are looking for it. In fact, it is only true to implement file sharing, configuring Samba very simple, just familiar with several operations. Here I use an example to indicate these operations. Suppose you are familiar with Linux's basic operation, such as the use of the VI editor, the basic operational file command.

Now we have three PCs, a Window2000 installed, the name is Test2000, there is a shared folder share; the rest is installed with Linux, and the name is Testsamba, there is a directory / Pub; another name is Testlinux There is also a directory / PUB. The goal we want to achieve is to share / pub on TestSamba for use in TEST2000 and TEST_LINUX.

We do the following: Test_SAMBA:

Locate SMB.conf under / etc /, open with the VI editor.

# vi /etc/smb.conf or vi /etc/samba/smb.conf

Under the [GoBal] field, add NetBIOS records, generally plus the next line of Workgroup record;

Netbios Name = Testsamba

Under the [GoBal] field, modify the SECRITY record;

SECRITY = Share

Under the [Public] field, modify the PATH record;

Path = / PUB

Add a Geuest OK record under the [Public] field;

Guest OK = YES

Delete the "public] field"; "indication;

Save exit.

Simply explained, the added NetBIOS Name is a machine name that can be seen in the TEST2000 network neighbor; the added / PUB is a shared directory that can be seen in a network neighbor; adding guest OK is allowing all users to access the sharing Delete ";" indicates that the entire [public] field becomes executable.

Now / Pub has become a directory that can be shared by TEST2000 and Testlinux.

Try it:

Under TestSamba, you can do the following for shared folders under Test2000:

# SMBCLIENT -L // TEST2000

This command is a shared situation in Test2000. Note that when the system is required to enter Password, you can enter the TEST2000 directly, and the sharing under TEST2000 is listed on the screen.

#smbclient

TEST2000 // Share -u Share (or SMBMount // Test2000 / Share / Pub)

This command can enter the Share directory of TEST2000, and the MS-DOS prompt appears: / when the user enters the Share directory. At this point, you can enter "?" To find the command you can use after the prompt.

Under Test2000, use TestSamba shared directory / PUB, you can do the following:

Find Computer Testsamba, when the TestSamba target appears, double-click the icon PUB, ready to enter the shared folder Pub.

Under Testlinux, use the Testsamba shared directory PU, which can be made: (assuming that Pub is known)

#SMBMount // Testsamba / Pub Pub

This command can hang the PUB under TestSamba on the PUB of this machine, and enter the transfer of Password directly on the system, then enter the #CD / PUB / PUB, # ls, and the screen is listed. Document. Win2000 and Linux implementation file sharing, simple!

Samba in the Linux system Xue Longqin, Wang Zulan 01-8-8 01:09:04

Preface:

In order to achieve resource sharing between Windows and Linux and other operating systems, software vendors launched two solutions for NFS and Samba. Due to the lack of client tools like PC-NFS, Linux and Windows resource sharing becomes complicated. The emergence of Samba solves this problem, which is more interested in more and more people with its simple, practical, flexible configuration.

Windows uses the SMB protocol to implement files and printer sharing between operating systems, while Samba itself has an SMB protocol, which implements resource sharing in the LAN and Windows Series Computer.

This article focuses on the configuration of Samba under the Linux system, discussing the resource sharing of Windows and Linux within the LAN.

First, Samba Introduction

1, SMB protocol

The SMB (Server Message Block, Service Information Block) protocol is a protocol for shared file / printers on the LAN, which can provide file systems, print services for other Windows and Linux machines inside the network. The SMB's working principle is to let NetBIOS and SMBs run over TCP / IP and use NAMSERVER using NetBIOS to let Linux machines can be viewed in Windows network neighbors.

2, Samba

Samba is a software for implementing SMB, developed by Australian Andew Tridgell, is a free software running in a Linux environment. It can do the following features:

File services and print services, implement Windows and Linux resource sharing.

The login server can be used as a server of the LAN.

As the main domain controller.

WINS server.

Support SSL.

Supports SWAT.

Second, Samba service

1, core process

Samba has two daemons: SMBD and NMBD, which are the core process of Samba. The NMBD process browsing other computers, and the SMBD process processes them when the SMB service request arrives, and coordinates for resources used or shared.

2, start the service

Samba has two startup methods: daemon form and inetd form.

(1) DAEMON forms started script: rc.samba

SMBD-D-D1

NMBD -D -D1

-D means executed in Daemon; -D1 indicates the inclination recording level

Perform script file rc.samba

(2) inetd form

Set file: / etc / services

NetBIOS -SSN 139 / TCP

NetBIOS -NS 137 / UDP

Set file: /etc/inetd.conf

Netbios -ssn Street TCP NOWAIT ROOT / USR / SBIN / SMBD SMBD

NetBIOS -NS DGRAM UDP WAIT ROOT / USR / SBIN / NMBD NMBD

Start inetd daemon

# kill -hup 1

3, customer tools smbclient

Use the SMBCLIENT command to access resources on the remote SAMBA server. Its command form is similar to FTP.

Command syntax is: #SMBCLIENT

[Password] [option]

(1) Explanation: ServiceName is the resource name to which you want to connect, the resource name is as follows: // Server / Service Server is the NetBIOS name of the remote server. For the Windows server, it is the name of the online neighbor.

Service is the name of the resources provided by each Server.

PSSword is the password required to access the resource

Option various command options, where -l is used to list all resources provided by the remote server

-I Specifies the IP address of the remote server. At this point, the NetBIOS name part in ServicesName will be ignored.

(2) A variety of SMBCLIENT commands:

After executing the smbclient command successfully, enter the SMBClient environment, the prompt: SMB: />

There are many commands and ftp commands, such as CD, LCD, GET, MEGT, PUT, MPUT, etc. Through these commands, we can access the shared resources of the remote host.

4, Samba system loading and uninstall

(1) Loading resources from other hosts

We can use the SMBMount command provided by Samba to load other host shared resources.

SMBMOUNT command syntax: # smbmount

Where ServiceName is the resource name, Mount-Point is the installation point.

For example: # smbmount "// server / TMP" -c 'mount / mnt'

Indicates: loading the shared resource "TMP" on a computer name "Server" to the local / MNT

Under contents.

(2) Uninstall resources

Uninstall a loaded SMB file system, use the SMBUnmount command, and specify the loading point to which you want to uninstal. For example: # SMBunmount / MNT

Third, Samba configuration

The configuration file of the Samba component is /etc/smb.conf, which contains almost all configuration information required for Samba system program runtime.

1, configuration options

There are more important sections in the configuration file: [Gloabal], [Homes], [Printers], the following gives the description.

(1) [GLOABAL] In the global parameter, the settings of the parameters directly affect the Samba system.

NetBIOS Name: Set the host name

Workgroup: Used to specify the NT domain name or workgroup name to which the host is located. Format

Workgroup = NT Domain-name or Workgroup-Name

Server string: Used to set this unit, the default is Samba Server

Host Allow: It allows which areas allowed to access its Samba server

Load Printers: Allows the list of printers to be loaded without having to set up each printer separately.

Interface: Configure Samba using multiple web interfaces.

Domain Controller: Use this option only when there is a network in the network to be installed as the primary domain controller.

Security: Set the security parameters to define security mode. Samba's security model has four kinds

Share, User, Server, Domain

Encrypt Passwords, SMB Passwd File: Used to apply the encryption password.

Here is a parameter configuration example:

[global]

SMB Passwd file = / etc / smbpasswd

REMOTE Announce = 172.18.158.234 172.18.153.55 172.18.153.255

DNS Proxy = NO

Security = useerencrypt passwords = yes

Server string = ftp server

Workgroup = Turing

Socket Options = TCP_NODELAY SO_RCVBUF = 8192 SO_SNDBUF = 8192

Log file = /VAR/LOG/SAMBA/LOG.%M

Load Printers = YES

Guest account = dscan

REMOTE BROWSE SYNC = 172.18.158.234 172.18.153.55 172.18.153.255

PrintCap Name = / etc / printcap

Max log size = 50

Hosts allow = 172.18.158. 172.18.153. 127.

...

(2) [Homes] Section All users' Home Directory

When any customer accesses the Samba server, you can share your own Home directory in the network resource. It is configured as follows:

[homes]

Comment = HNNW Directories

Browseable = no

Writable = yes

(3) User Share Directory

Used to specify a directory configuration for a particular user group or user has access rights, the following parameters Configure only the user who has the right to access the directory / home / samba.

[public]

Comment = public hnnw

Path = / home / samba

Public = yes

Writable = yes

Printable = NO

Write List = @hnnw

2, user mapping

The global parameter "username map" is used to control user mappings, which allows administrators to specify a mapping file that contains information on user mapping between clients and servers.

Such as: username map = / etc / smbuser

User mappings are often done between Windows and Linux hosts. The two systems have different user accounts, and the purpose of the user mapping is to make different user mappings into a user, which is easy to share files.

Below is an example of a mapping file:

# Map Windows Admin to Root

root = administrator

Map the Member of Developer to Studio

Studio = @Developer

The left side of the equal sign is a separate Linux account, the right side is the list of accounts to be mapped.

The server is analyzed by line by line. If the supplied account and the account in the right list match, put it

Replace the account on the left of the equal sign.

3, use encryption password

The new version of Windows 95 and Windows98, Winnt (SP3 or higher), only pass only the encryption password as user authentication in the network transmission. This type of client and the Samba server that do not support the encryption pass and the Samba server running in the User security level will fail. For normal communication, the Samba server uses an encrypted password. Here is how to use encrypted passwords in Samba.

(1) Password file / etc / smbpasswd

In order to use the encryption password, Samba requires a password file (/ etc / smbpasswd), and the file should be synchronized with Linux password file (/ etc / passwd). Below is the generated file command:

# CAT / etc / password | mksmbpasswd> / etc / smbpasswdsmbpasswd is the required password file, whose permissions are 0600, the owner is root

The record of the SMBPASSWD and Passwd files corresponds to the password. Password has two parts, each part

It is 32 "X", the front part is used to communicate with the LANMAN communication, the back part, and Windows NT.

Root users can use the smbpasswd command to set Samba passwords for each user.

(2) Modify the configuration file /etc/smb.conf

To make Samba use encrypted passwords, you need to add the following parameters in the configuration file SMB.conf.

Encrypt passwords = yes

SMB Passwd file = / etc / smbpasswd

The first line notifies Samba to use the encrypted password, the second line to the location of the port file.

(3) Restart Samba services.

After modifying the configuration file, you need to restart the Samba service, you can use the following command:

# / usr / sbin / samba restart

4, clear password in the Windows system

In the Samba system, the clear password is used as the default setting for the connection SMB. When the SMB server responds to the negotiation protocol, the response information contains a bit to illustrate whether the server supports inquiry or responding. With the release of Win95's network redirection update, Microsoft modifies the default value so that Windows customers will not send a clear password to unsupported servers.

In this case, there are two solutions:

(1) Set the Samba server to use the encrypted password

(2) Let Windows customers use clear passwords

The second solution is used here, and it is achieved by modifying the registry. The following will be given to the WIN95 / WIN98, WINNT users.

(1) WIN98 / WIN95 system user

Add the following registration words in the registry and restart the machine:

[HKLM / System / CurrentCntrolset / Services / VXD / VNETSUP]

"Enableplaintextpassword" = dword: 00000001

(2) Winnt system users

Modify the registry, add the following registry key, and restart the machine:

[Hklm / system / currentcntrolset / services / rdr / parameters]

"Enableplaintextpassword" = dword: 00000001

Fourth, Samba application

1, Windows resource sharing and use

(1) Windows resource sharing

a. Use TCP / IP protocol as a network default communication protocol

b. Modify the network configuration, set files, and printer sharing.

c. Set the computer name and the working group

d. Shared system resources

(2) Use Linux shared resources in the Windows system

a. Log in into the Windows network

b. View online neighbor, use shared resources.

c. Command line tools use shared resources

Use the Net.txt tool in the command to view, use shared resources:

The syntax of the NET USE command: C:> NET use x: // servername / sharename

Here, x: is a shared drive letter, // servername / sharename is a network path to the shared UNC.

For example: C: /> Net Use H: // hey / myfile

Represents: Map the MyFile shared resource on the Hey machine to the local H disk

2, Linux resource sharing and use

(1) Sharing Linux resources

Add Linux resources that you need to share by editing Samba profiles. At the same time, you can set the user base and its access rights to this resource. Below is an example, share this / public / data directory, all people have read and write permissions.

[data]

Comment = public data

PATH = / public / data

Public = yes

Writable = yes

Printable = NO

(2) Use shared resources in Linux

You can use the SMBCLIENT command to access all SAMBA resources. See the foregoing details.

V. Samba app

SMBCLIENT: Access all shared resources

SMBSTATUS: List all current Samba connection status

SMBPasswd: Modify the Samba user password to increase Samba users.

NMBLOOKUP: Used to query the host's NetBIOS name, and map it to an IP address

TestParam: Whether the parameter settings in the configuration file are correct

Samba configuration in Linux system

转载请注明原文地址:https://www.9cbs.com/read-80449.html

New Post(0)