Detailed tutorial on how to build samba in Linux and how to build samba in linuxsamba

Source: Internet
Author: User
Tags ldap

Detailed tutorial on how to build samba in Linux and how to build samba in linuxsamba
Samba Setup 1. samba Configuration
1. the samba service is similar to the sharing Function on windows. It allows users to share files on linux and access files on linux and windows. It is a communication protocol for sharing files and printers on a LAN, provides sharing services for files, printers, and other resources between different computers in the LAN.
2. install and configure samba
(1) yum install-y samba-client
Edit configuration file
Vi/etc/samba/smb. conf

[Global] // indicates global configuration of workgroup = MYGROUP // workgroup server string = Samba Server Version % v // server name log file =/var/log/samba/log. % mmax log size = 50 // log cutting security = user // samba security level. share indicates that verification is not required, and user indicates that the user name and password are required, server indicates that another server is responsible for user authentication. domain specifies a windows server to verify the user information. passdb backend = tdbsam // The user background, three smbpasswd, tdbsam, ldapsamload printers = yescups options = raw [homes] // user's Home directory comment = Home Directories browseable = no writable = yes [printers] // printer related comment = all Printers path =/var/spool/samba browseable = no guest OK = no printable = yes
Load printers and cups options are used to set printer problems.
Netbios name = MYSERVER: Set the host name that appears in the network neighbor.
Hosts allow = 127. 192.168.12. 192.168.13. 172.16. Set the allowed hosts. If commented out, all hosts are allowed.
[Homes] This part of content shares the user's home directory. When a user logs on to the samba server, it actually enters the home directory of the user. After the user logs on, the sharing name is homes, it is the identifier of the user. you can comment out this part.
[Printers] Set printer sharing

(2) Case 1
To share a directory, anyone can access it. Read-only is required;
Modify smb. conf:
Workgroup = WORKGRUOP
Security = share
Add module share
[Share]
Comment = share all
Path =/tmp/samba
Browseable = yes
Public = yes
Writeable = no // control whether to write

In windows, use the resource manager and enter \ 192.168.1.119 to access:


In linux, you need to install smbclient:
Smbclient // 192.168.1.119/192.168.1.119
Linux can also mount the samba directory. You need to install the cifs suite:
Mount-t cifs // 192.168.1.119/192.168.1.119/mnt/
(3) Case 2
To share a directory, user authentication and read/write are required.
[global]workgroup = WORKGROUPserver string = Samba Server Version %vsecurity = userpassdb backend =tdbsam

Add module:
[myshare]comment = share for userspath = /tmp/sambabrowseable = yeswritable = yespublic = no


Create user information:
The old version uses smbpasswd to create user information, and the new version uses pdbedit.
Smbpasswd-a user1 creates logon information for user1.
Pdbedit-a user1 creates logon information for user1.
Pdbedit-x username Delete samba account
Pdbedit-L list Samba users and read the passdb. tdb database file
Pdbedit-Lv: List Samba user details
Pdbedit-c "[D]"-u username pause this Samba User Account
Pdbedit-c "[]"-u username restore this Samba User Account
Ldapsam: to verify users based on LDAP account management, you must first create an LDAP service and set "passdb backend = ldapsam: ldap: // LDAPServe"
Log On As user1:
smbclient -Uuser1 //192.168.1.119/myshare

Note that at this time, the client is operating with the identity of the server user user1. You can see that the owner Group of the new directory aaa is user1.


When you access \ 192.168.1.119 through a resource browser in windows, you are prompted to enter the user information:



In this case, you need to add the user information parameters for mounting in linux:
mount -t cifs -ousername=user1,password=123456 //192.168.1.119/myshare /mnt



(4) Case 3
Two directories are shared. One directory is a public directory, which is accessed by anonymous logon.
User authentication is required for another directory.
[Gloabl] some new additions:
map to guest =bad userguest account = nobodyencrypt passwd = yessmb passwd file = /etc/samba/smbpasswd

Directories Accessed Anonymously:
[public]comment = publicpath = /data/pub/publicbrowseable = yesguest ok = yeswriteable = yesprintable = nocreate mask = 0644directory mask = 0755

User Authentication directory:
[public]comment = projectpath = /data/pub/projectbrowseable = yesguest ok = nowriteable = yesforce user = rootprintable = nocreate mask = 0644directory mask = 0755

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.