Build a Samba server on fedora 14 (SELinux needs to be set out)

Source: Internet
Author: User

The Samba server can share files between Windows and Linux. the SMB protocol is an application protocol built on the NetBIOS protocol. It is a service based on the tcp138 and 139 ports. When NetBIOS appears, microsoft uses NetBIOS to implement a network file/print service system. This system sets a file sharing protocol based on NETBIOS, which Microsoft calls SMB (Server Message Block) protocol. This protocol is used in LAN Manager and Windows Server systems, allows different computers to share printers and files.
Fedora Samba enables SMB to run on the NetBIOS protocol, and uses the netbeui protocol of windows to allow Unix/Linux servers to be accessed on Windows Network neighbors.

During embedded Linux development, it is inevitable that files and printing will be shared between the Linux host development environment and the Windows operating system. Of course, there are various implementation methods, here, I create a Samba server under fedora14 to share files between fedora and windows.

1. Install the Samba server
You can install Samba online through yum.
Yum-y install samba
Of course, you can also choose system-management-Add/delete programs to install them. Search for smaba in the window and select the appropriate program version for installation.
(During installation, make sure that Yum is available and the network configuration is correct .)

Ii. Configure the smaba Server
The configuration is mainly implemented by editing/etc/samba/smb. conf. (Read/write permission, Su to root)
You can use chmod 777 smb. conf to edit the file in a text editor. You can also use VI to edit the file directly.
[Root @ localhost ~] # Vi/etc/samba/smb. conf configure edit the configuration file of Samba ora samba
Workgroup = workgroup // set a Working Group
Server String = % u's samba % v // description % u indicates the current Login User
NetBIOS name = fedora // NetBIOS name. fedora9 is not enabled by default.
Log File =/var/log/samba/log. % m // log file storage PATH % m your Windows Host Name
Max log size = 50 // maximum log capacity
Security = user // security level. The user must have the user name and password, but not the share level.
[Fedora Samba] // create a share named fedora samba
Comment = Samba // description
Path =/home/BSC/samba // shared path
Public = No // whether to allow access by the guest user (equivalent to guest OK = yes/no)
Writable = Yes // whether to write
Write list = BSC // a list of users that can be written (@ represents the user group)

3. Create a shared directory
[Root @ localhost ~] # Mkdir/home/BSC/samba plugin create a dedicated directory for shared files
[Root @ localhost ~] # Chown-r nobody/home/BSC/samba secrets set the private directory to nobody
[Root @ localhost ~] # Chmod 777/home/BSC/samba/secrets set the private Directory attribute to 777
[Root @ localhost ~] # Smbpasswd-a BSc login: add the System user BSC (this user must not exist. If not, add useradd name) to the samba ora Samba user database.
New smb password: Login enter the password used by the user to log on to Samba
Retype new smb password: Confirm again to enter the password
[Root @ localhost ~] #
Step 4 start the samba Service

First, open the firewall.
[Root @ localhost ~] # Vi/etc/sysconfig/iptables configure edit the iptables configuration file
-A input-M state -- state new-m tcp-p tcp -- dport 25-j accept find this row and add the following row below:
-A input-M state -- state new-m tcp-p tcp -- dport 139-J accept
-A input-M state -- state new-m tcp-p tcp -- dport 445-J accept
-A input-p udp-m udp -- dport 137-J accept
-A input-p udp-m udp -- dport 138-J accept
Restart iptables to make the modification take effect:
[Root @ localhost ~] #/Etc/rc. d/init. d/iptables restart. Show OK

Finally, start the samba ora SAMBA service (including two Daemon Processes: SMB and nmb ).

[Root @ localhost ~] # Chkconfig SMB on startup set fedora Samba to start automatically
[Root @ localhost ~] # Chkconfig -- list SMB restart confirm the samba ora Samba startup label and check that 2-5 is in the on status
[Root @ localhost ~] # Chkconfig nmb on startup
[Root @ localhost ~] # Chkconfig -- list nmb logs confirm the nmb startup tag and check that 2-5 is in the on status
Nmb 0: off 1: off 2: On 3: On 4: On 5: on 6: Off
[Root @ localhost ~] #/Etc/rc. d/init. d/SMB start (or service SMB start) Restart start the samba ora SAMBA service
Starting SMB services: [OK]
[Root @ localhost ~] #/Etc/rc. d/init. d/nmb start worker start nmb Service
Starting nmb services: [OK]

If the Samba server is successfully created with the above configuration, test it.
Open windows. Run --> \ your Linux IP address ([root @ localhost ~] # Ifconfig view IP address), OK !!! The shared folder is displayed. Okay, Samba is fully configured, but is it true? When you try to open a folder, you find that you do not have the permission.
Note:
In other versions of Linux (As5, as4, centos), after setting the above settings, you can access and share normally, but not in fedora. We can only see sharing, however, access is denied. Why? Because SELinux imposes limits on Samba sharing, we only need to solve the limitations on Samba in SELinux. We can make the following settings:
# Setsebool-P samba_enable_home_dirs on
# Setsebool-P samba_export_all_ro on
# Setsebool-P samba_export_all_rw on
Run getsebool-A | grep Samba.
Check whether the preceding three items are enabled. If yes, your sharing will be normal.

For the convenience of development, there are many convenient tools in windows, so I decided to use the samba service. However, by default, my Windows users are not granted administrator permissions, so for convenience, setting Windows users shared by Samba under fedora as root saves the files created by root under fedora and requires chown to be edited in windows.
First, go to/etc/samba/, back up smbusers, modify this file, delete other accounts in the root line, only the accounts you will use, and then share them.

You can also use the graphic interface, but you also need to delete the entire line of root first.

1 # unix_name = smb_name1 smb_name2...
2 nobody = guest pcguest smbguest
3 root = lry

The above is for the user mode.

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.