Samba Server Introduction

Source: Internet
Author: User

Samba is a free software that implements the SMB protocol on Linux and UNIX systems, consisting of servers and client programs. SMB (Server Messages block, information service blocks) is a kind of communication protocol for sharing files and printers on LAN, which provides shared services of files and printers among different computers in LAN. The SMB protocol is a client/server protocol that allows clients to access shared file systems, printers, and other resources on the server. By setting up "NetBIOS over TCP/IP", Samba will not only share resources with local network hosts, but also share resources with computers around the world.

Kit InstallationIn fact, the installation of SAMBA is not difficult, and in the main distribution above are provided, also all the same, so it is recommended to use the distribution provided by the RPM file to install! Of course, you can also use Tarball to install it yourself! ① It's not hard to use RPM to install the RPM installation. However, be aware of the installed suite name, because different distribution for RPM file naming are not the same! For example, Red Hat 9 requires a total of at least three packages for the Samba server, namely: Samba: This kit consists mainly of Samba's main daemon files (SMBD and NMBD), Samba file files, and other samba-related logrotate settings files and boot preset options files. Samba-common: This kit mainly provides the main settings of SAMBA (smb.conf), the test procedure of smb.conf Grammar test (testparm), etc. samba-client: This kit provides the tool instructions that are required when Linux is the client side of samba, such as the execution file Smbmount, which mounts the Samba file format, and so on. However, in Mandrake 9.1, the samba package is divided into Samba-server and Samba-doc two kits, so there are four kits to install in MDK 9.1: Samba-server, Samba-doc, samba-c Ommon, Samba-client. ②RPM installation: Take out the disc, mount him, and then give him the samba kit on the RPM! At the end of the test, your system should look something like this (take red Hat 9 for example): [[[email protected]] #rpm-qa | Grep sambasamba-common-2.2.7a-8.9.0redhat-config-samba-1.0.4-1samba-2.2.7a-8.9.0samba-client-2.2.7a-8.9.0 Note that the example shown above is red The file for Hat 9, where the Redhat-config-samba is an additional set-up feature of Red hat that can be used without installation. ③ use Tarball to install in general, because each distribution provides the same functionality as SAMBA, there is no need to use Tarball for additional installation and setup, but if you still want to build your own samba, you can Samba's official website downloads Samba's original program code and compiles it on its own machine. [[email protected]] #wget http://ftp. Xx/unix/samba/samba-2.2.8a.tar.gz[[email protected]] #cd/usr/local/src[[email protected]]# TAR-ZXVF/ Root/samba-2.2.8a.tar.gz this time there will be a directory running out:/usr/local/src/samba-2.2.8a[[email protected]]# CD samba-2.2.8a # ( Check the readme in this directory) [[email protected]]# CD Source[[email protected]]#./configure--prefix=/usr/local/samba\>--with-automount--with-smbmount--with-pam \>- -with-mmap--with-quotas--with-libsmbclient1. Please take a look at the./configure--help for some of the relevant parameter usage of Configure 2. If any errors occur, do not move down the make, because it is still wrong! 3. In case of any errors, usually due to some function library can not be found, please refer to this directory of Config.log the contents of this file, which will record some errors in the course. [[email protected]] #make # (Start compiling!) This process will take some time because he will just set the original code (source code) and compile it with GCC compiler! So it takes some time [[email protected]]# make install installs the executable binary file that was just compiled into/usr/local/samba in this example, you will need to be in the future when you set up Samba Usr/local/samba in general, unless the Linux distribution is already quite old (for example, the previous version of Red hat6.x), and on the old system is running some of the services, and just want to increase the services of samba, it has to use Tarball Way to install Samba, otherwise, it's pretty strong advice to install your Samba server software directly in RPM! Because it is simple and convenient, and easy to set up uniformly. Server-side settings because SAMBA is almost certainly included in each of the major Linux distribution, and the difference in functionality between versions is not very large, we've all described the SAMBA package installed in RPM .。 Of course, even the same RPM file, but in each Linux distribution, SAMBA's main files may be placed in a different directory. However, since Samba's profile name is constant (smb.conf), although we are using red Hat 9 as an example below, you can still use locate, find, whereis and other instructions to find the SA under different distribution systems. MBA major profiles and execution files Oh! (That's why we like to teach you how to learn Linux using VI and plain text mode because one FA Tong, Lawspirit TongAh! In addition, my first example is to set up and test the case without a firewall, if you have a firewall in your environment, then you should first understand the architecture of the firewall, and samba needs to open the port to him, otherwise it is difficult to test success Oh! Or look directly at the section later in this chapter on security, especially Iptables and/etc/hosts.allow (Deny).Kit StructureWe're here to introduce some of his profile and execution files in the Red Hat 9 SAMBA suite, but it doesn't matter if your distribution isn't Red hat 9, because it's all the same! Use locate this command to search for Oh!configuration fileIn earlier versions, SAMBA's profiles were placed directly under/etc, and later versions were placed under the/etc/samba (some distribution in/ETC/SMB and/ETC/SAMBA.D, using loc ATE search! )。 Some of the important profiles under/etc/samba are: /etc/samba/smb.conf: This is the most important setting for Samba! In a simpler setting, this is also the only set file! In addition, this file itself contains quite a lot of instructions, so, before setting, please use VI good detail to watch this file! The main setting of this profile is divided into two parts, which are [global], which is the setting of the host function, and the subsequent properties of each shared directory. /etc/samba/LMHOSTS: The main purpose of this file is to correspond to NetBIOS name with the IP of the hostname, in fact, he is a bit like the/etc/hosts feature! Only the hostname of this LMHOSTS corresponds to NetBIOS name Oh! Don't get confused with/etc/hosts! Since Samba is now more powerful, it is usually possible to get the NetBIOS name of the relevant computer on the LAN as soon as you start Samba, so this file is usually not set up. /etc/samba/smbpasswd: This file preset does not exist. It is a table of user password corresponding to Samba presets. When the set SAMBA server is more stringent and requires the user to enter the account and password to log in the state, the user's password preset is placed here ( of course, you can set the location of the password and the password file name in the smb.conf, however, we are here in a preset state to explain) 。 The comparison needs to be noted, this file because contains the user's password, so, of course, the authority to pay more attention! The owner of this file needs to be root, and the permission is set to 600.Execute FileSamba execution files in general, as a samba Server execution file has testparm,smbd, NMBD, SMBPASSWD, as for the Samba Client execution file is mainly: Smbmount,smbclient. SMBDAnd NMBD: These two execution files are the two main daemons, and each time SAMBA is launched, it will use two execution files. Testparm: This testparm is needed to view all of SAMBA's set parameters and smb.conf settings after the smb.conf has been set to complete the main profile ( shorthand for test parameters! )! So, every time after modifying smb.conf, be sure to use testparm to see if there is a set error. smbpasswd: If Samba is set to a stricter setting, the user's account number and password need to be specified, then the password file will need to be built using SMBPASSWD, so this command is related to setting up SAMBA's password. Smbclient: When a Linux host wants to see the directories and devices shared by other computers by using the "Followmission on the Network" feature, you can use Smbclient to view them! This command can also be used on the SAMBA host to see if the setting is successful. Smbmount: On Windows can be set "network disk drive" to connect to the host, similarly, on Linux, you can use the Smbmount to the remote host to share files and directories mounted on the Linux host. However, it is also possible to use the Mount command directly for the same function. [1]Related catalogueThis part needs to be paid more attention to is Samba's "login file". Since recently, the use of "network Followmission" to destroy the virus is more and more! There are more and more funny people will be followmission on the network of the relevant loopholes to invade the trick, so, to understand the location of the login file placement, and analysis, you can get a small monitoring. /usr/share/doc/samba: contains all relevant technical manuals for samba. In other words, when Samba is installed, the system already contains a fairly rich and complete samba user manual. /var/log/samba: SAMBA preset Log-in file placement directory. If SAMBA is not always set up, or if it is suspected of being invaded by a port 137~139, it is here to observe. /usr/share/samba/codepages: Places the supported formats for each language. For example, to allow Samba to support Chinese, you need to codepage.950 this file for support. In the smb.conf inside the set can.Application FeaturesThe development of Samba, as illustrated above, shows that the main goal of Samba's initial development was to communicate the two different platforms for Windows and Unix like. The biggest benefit is that you don't have to keep the same data in a different place, and then you don't know which one is up to date! It is also possible to make it easier to transfer files from Linux to Windows through such a file system! In other words, the transfer of Linux and Windows files can be done through "followmission on the Network". So what can SAMBA do? ① share file and printer services; ② provides user authentication to log on to the SAMBA host to provide individual data for different identities, ③ for Host name resolution (NetBIOS name) on the Windows network ④ share the appliance (for example, Zip, CDROM ...)Main partTwo daemons: SMBD and NMBD (NetBIOS name Service for clients) Profile:/etc/smb.conf using tools: Smbclient,smbstatus,smbmount,smbumount,smbprint, Smbprint.sysv,smbrunsamba startup script in the/ETC/RC.D/INIT.D/SMBBTW, do not confuse SMB with SMP (symmetric multiprocessor), not the NetBIOS name and DNS host name confused! Samba defaults to setting the hostname to NetBIOS name, which usually exceeds the length limit (16 characters) of the NetBIOS name. SMB MethodWhen the logged in user tries to connect to the remote computer network sharing, for example, the \\server\myshare,windows client will automatically transfer the login data of the logged-in users to the SMB server before obtaining any username or password from the consumer, in this step, if the authentication fails, Windows will pop up a window asking for the user name and password. In general, SMB dialogs are established in the following order: "TCP Connection" – Establish 3-way handshake (wired) to port 139/tcp or 445/tcp. "NetBIOS Session Request" – Use the following "calling Names": NetBIOS name plus 16th character 16th character 0x00: Server NetBIOS name plus 16th character 0 x20 "SMB Negotiate Protocol" – the protocol dialect that you decide to use will be one of the following: PC Network Program 1.0 (CORE) – Just share level security mode; Microsoft Networks 1.03 (Core P LUs) – Just share the level security mode; Lanman1.0 (LAN Manager 1.0) – Use Challenge/response authentication;lanman2.1 (LanManager 2.1) – Use Challe Nge/response authentication; NT LM 0.12 (nt LM 0.12)-Started with the Challenge/response authenticationsmb dialog, the password is encrypted (or unencrypted) in one of the following ways: Null (no encryption); cleartext (no encryption); LM and Ntlm;ntlm;ntlmv2. The password is then confused and transmitted to the computer that asked for the conversation (ironically, this step will be done before the password is required). SMB Tree Connect: The name of the connection share (for example: \\servername\share); Connect to a service type (for example: ipc$named pipe)Network NeighborhoodThe Linux box is not visible in Win95 's Network Neighborhood note the following settings in the/etc/smb.conf file: Guest account = Pcguest (do not write, add the actual name, you are going to create a pcguest account) null Password = Yes (this is important!) ) browseable = Yespublic = yes also change security to share. Read the "man smb.conf" carefully. Besides, Win95 the broken thing, The Network Neighborhood runs 100 times before it can come out what you want. Use this method to try it: First use a shared directory of Smbmount Win95, use "Network Monitor" to see it, and then use the online neighborhood.How to useCan't you see it with man Smbmount? Roughly: Smbmount//win95-name/share-dir/mount-point [-I IP address or hostname] [-C Native Client name] [] means optional, native Client name can be taken. Samuel Leo added: The standard smbmount use format is Smbmount//server/share-c "Mount/mnt-u uid-g gid" (Note: it seems wrong) I compiled a modified version of Smbmount, Use format Smbmount//server/share/mnt [passwd] [-uusername] [ -9]ftp://202.103.190.5/incoming/smbmount.gz (binary) If you use Redhat, you can also try the latest smbwrapperftp://202.103.190.5/incoming/smbwrapper.so.gz set the environment variable Ld_preload=/anywhere/smbw_ User=usernamesmbw_password=passswordsmbw_workgroup=workgroup #optionalSMBW_DEBUG =4 #optionalSMBW_LOGFILE = Smbw.log #optional, default to STDERRSMBW_PREFIX=/SMB #optional, default To/smbexport PWD smbw_user smbw_password smbw_ Workgroupexport smbw_debug smbw_logfile Smbw_prefix then you can "LS/SMB" See all the machine names in the same group. " Ls/smb/server "Look at the shared list of the machine. The disadvantage is too slow, version 10.10 to Execle,execve, ... such as the designated ENVP exec still have a bug can not be executed under the/SMB file, cannot mmap/smb under the file .> Thank you first! > My Pwin95 can now see Linux, and I promise nothing has been changed. > Now, I'm executing:> smbclient//sjj2/nes (Pwin95 machine) from Linux, see the file and show:> smb:\>> smbclient-l sjj2, see Sjj0 (Linux) and Sjj2 (Pwin95). > But I can't access Linux from Pwin95 (sjj0), double-click the total display:> can't find the machine name or share name, make sure the input is correct, and then try again. > I will not use Smbmount, can not find the help to see clearly, because > I do not understand the meaning of mount-point, please guide; the > SMBD and NMBD on Linux are, of course, running. > Thank you Again! Please continue to help. Smb.conf in the previous posts. Win95 's network neighbors too much problem, don't say with Linux, is a few Win95 between a small network, as long as there is no NT Server, they often can't find each other. Therefore, be sure to turn on the WINS server feature of samba (WINS support = yes), and then point the 95 WINS server to him. Maybe join: name resolv order = WINS hosts bcast doing so would be best to start Linux before Win95!Password Issues>; I in Redhat 5.1 can share Win98 service, in Win98 's Network Neighborhood >; can see Linux machine, but prompt \\linux\IPC$ need password, input password total >; Incorrect, do not know how to set? This problem seems to be not only Linux, NT also has, because the connection when no user name information, do not directly click on the icon, with Disk mapping: \\linux\username format. Win98 uses encrypted password authentication, while the SMB default for Redhat uses clear text authentication, so passwords are always incorrect. You can add encrypt passwords = Yes in smb.conf and use SMBPASSWD to maintain the user's password Win98 start-and-stop, log on with the username and password on the Linux machine, and access the Linux resources without entering a password The This is the same as on NT. or change the/etc/smb.conf on the Linux machine to security = share,guest account = Username (username to a user on your machine). This way, if Win98 is not logged on with a user account on a Linux system, it can also access Linux directly, with permissions equal to the permissions of the user specified by the Guest accounts. Reboot the Linux after making changes. Note: You do not have to restart at all, you can go down to/ETC/RC.D/INIT.D to perform SMBD stop, and then SMBD start (which is in Redhat). Learn the basics of not restarting as much as you can in Linux!Send plaintext PasswordIf you use Win98 or hit a lot of patches of Win95. If Samba does not provide password encryption, it cannot log on. 1. Execution Win95_plainpassword.reg allows Win95 to send a plaintext password to run regedit, adding: [Hkey_local_machine\system\currentcontrolset\services\vxd\ Vnetsup] "EnablePlainTextPassword" =dword:000000012. Upgrade to the latest samba, turn on password encryption switch .> BTW: Which version of Samba can be set to encrypt the check, how to set? My Samba 1.9.18p10 is ready. Find in Smb.conf # You can wish to use password encryption. Please read# Encryption.txt,win95.txt and WinNT.txt in the Samba documentation.# does not enable this option unless Read those documentsencrypt passwords = yessmb passwd file =/USR/PRIVATE/SMBPASSWD This paragraph is ready.relatedSmbclient \\NetBIOS-name\share-dir wrong? This is the shell's reason, should be used smbclient \\\\name\\share-dir or smbclient ' \\name\share-dir ' shell does not handle the content between two single quotes. If you're familiar with C, you should know why! Or use smbclient//netbios-name/share-dir there is no such problem. > I set the smb.conf on my Linux machine as follows (by deleting all comments), why does NT not recognize samba? change Security = user to: Security = Serversamba 1.9.18 Previous version also does not fully support the so-called "domain" NT, 2.0.0 is under development, there is no small progress .> more Shei Yaofei hero on the back of the guidance. But I ran into problems when I installed it. I chose Shadow,no pam,> also chose disk quota, the result appears > quotas.c:38:sys/quota.h:no such file or director> this can not be compiled later. I took the option to shadow no pam,no quota, there was compile, appeared:> cc:internal Compoler Error:program cc1 got fatal signal 6> make:* * * [Smbpass . o] error!> I choose the option of shadow,pam quota and so on, and this error always does not change. As if the previous compilation > passed it is not compiled only after the compilation. How can I get it to recompile? > Slackware 3.4 Kernel 2.0.30> thanks! If you're using Slackware 3.4, it's shadow,no pam,no. Quota probably from the beginning of 1.9.18P4 can not compile properly, to the SMBPASS.O must make this mistake. There are several workarounds: 1. Download the compiled file directly 2. Upgrade GCC to 2.8.1, or egcs-1.0.23. Upgrade to Slackware 3.5> I unit Finance Department need to install a file server, I installed Redhat 5.1, with samba> as a file server, the client is using Win95, now Win95 can be found in the Network Neighborhood > server, I will share the catalog mapShot to F: disk, after trial, large copy of the file is no problem .> However, because the financial software is a DOS mode, when I execute f:\ under the accounting procedures, once, twice, > even several times no problem, but a number of times after each client has a panic phenomenon. I will samba> stop a bit, and then start on it, how is this one thing? The previous use of NT Server did not > such a phenomenon. I used to use RH 4.2,kernel 2.0.30+ Samba 1.9.16P11 also have the same problem after update is OK, now I use kernel 2.0.35 + Samba 1.9.18P8versionDecember 04, 2012, Samba 4.0 RC6 released. [2]

Samba Server Introduction

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.