& Lt; Practice & gt; set up a samba server in centos and access it through the windows Platform

Source: Internet
Author: User

Introduction:

Recently, other audit teams found that samba was used for cross-platform file sharing. I just applied for a CentOS machine, so I wanted to build a samba server to play with it, I saw a topic on 51cto:

Http:// OS .51cto.com/art/200512/12843.htm

I learned a lot about samba. After mastering the basic principles, I tried it very well. It took 20 minutes to get KO.


Practice:


Part 1: Basic installation

UseYum installTo install samba.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/114959EP-0.png "title =" 1.png" alt = "154840862.png"/>

The dependency is automatically parsed here.


Select Y along the way. At last, samba and its dependent packages are installed:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495a630-1.png "title =" 2.png" alt = "154958644.png"/>


Start samba now:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495a317-2.png "title =" 3.png" alt = "155124396.png"/>


Make sure that the samba service is enabled:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495a024-3.png "title =" 4.png" alt = "155210250.png"/>


Part2: configure the samba server


Vi/etc/samba/smb. conf


Configure[Global]It provides global settings

Workgroup is configured in a workgroup. If LAN access is better for all machines in the same workgroup

Hosts allow configures which hosts can access this samba server, because I only want local or LAN access, and the IP address prefix of the LAN is 192.168.

The final configuration is as follows:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495aX2-4.png "title =" 6.png" alt = "155627965.png"/>


The following configuration[Homes]It is mainly used for samba users to access their home directories through what rules and constraints

If browseable is set to yes and writable is set to yes, the logged-on samba user can both read and write their own home directories.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495a0b-5.png "title =" 7.png" alt = "155914557.png"/>


We do not need to configure the shared printer service for the moment.


The following configuration[Netlogon]Part:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149594639-6.png "title =" 8.png" alt = "160130105.png"/>


By default, samba users can only access their own directories. To allow multiple users to share access to a directory, we configure the [public] section:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149593555-7.png "title =" 9.png" alt = "160251101.png"/>


Next, we useTestparmCommand to test whether our configuration is correct:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149593221-8.png "title =" 10.png" alt = "160351838.png"/>

"Loaded services file OK", Indicating that the configuration is correct.


Restart samba to make it take effect.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149595O1-9.png "title =" 11.png" alt = "160511680.png"/>



Part 3: Disable CentOS Firewall

When I try to access the samba server in windows XP installed on my own desktop, the following error occurs:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495a092-10.png "title =" 12.png" alt = "160742594.png"/>

It is very simple. We often encounter this problem, because we get a newly installed CentOS system, and the default firewall is on, so we can close it:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495923N-11.png "title =" 13.png" alt = "160832652.png"/>


You can access this machine this time, but the system prompts you to enter the user/password:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149593031-12.png "title =" 14.png" alt = "1611187.png"/>


Part 4: Create a samba account and password for access:

According to relevant articles, the account used to access the samba server must be an account managed by the operating system of the samba server. To this end, add a system account. Assume that we have created samba ):

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495aM0-13.png "title =" 15.png" alt = "161630527.png"/>


We create a new system account as a samba server account and create a samba password for it. Assume that the password we set here is samba_password ):

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149596100-14.png "title =" 16.png" alt = "161753273.png"/>

Until"Added user samba"Is successful.


Restart the samba server and log on to the samba server (samba/samba_password) from windows:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/11495941W-15.png "title =" 17.png" alt = "161918702.png"/>


Part 5: Disable centos's security management restrictions

After successfully logging on to 192.168.71.43, when we access the samba directory, we are denied:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149594P1-16.png "title =" 18.png" alt = "162038968.png"/>


This is strange.Smb. confIn the [homes] moduleBrowsable = yes,Valid user is also configured. Why not let us access it? This plagued me for a while, and later I found the cause. It turns out there isSelinuxModule, which adds Access Security Control for centos:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149595336-17.png "title =" 19.png" alt = "162254551.png"/>


The defaultSELINUXSetEnforcing, Indicates that security control is enabled by default, so the windows system is blocked from accessing the file resources of the centos system.DisabledTo disable this security management, as follows:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149593346-18.png "title =" 20.png" alt = "162427164.png"/>


After saving the file, restart the centos system and access the file through windows. This time, we finally successfully logged on with the samba user name and can access the resources in the corresponding samba directory home directory on the samba server:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131229/1149596338-19.png "title =" 21.png" alt = "162559832.png"/>



Summary:

The installation and configuration of the samba server is relatively simple. I hope this article will be useful for you, but I haven't covered many complicated functions yet. However, the topic of BKJIA is indeed good, we strongly recommend that you take a look.


This article from "parallel line cohesion" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1344093

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.