Samba services implemented in Windows shared files

Source: Internet
Author: User
Tags ldap

1. What is Samba
The Samba service is similar to the sharing feature on Windows, which enables you to share files on Linux, access them on Windows, and, of course, access them on Linux.
is a kind of communication protocol that share files and printers on LAN, it provides the sharing service of files and printers among different computers in LAN.

2. Package required to install the Samb

Yum Install-y Samba Samba-client

3 main configuration file/etc/samba/smb.conf its contents

Vim/etc/samba/smb.conf

In global configuration [global], change workgroup = MyGroup to Wokgroup = Wokkgroup because the default workgroup under Windows is Wokrgroup

#netbios name = Deanhehiehei//followed by the hostname you displayed in your Windows Network Neighborhood

Security = User #这里指定samba的安全等级. There are four types of safety levels:
Share: Users do not need an account and password to log in to the Samba server
User: The Samba server providing the service checks the account and password (default)
Server: Checking account and password work is done by another Windows or Samba server
Domain: Specifies the Windows domain control server to verify the user's account and password.
Passdb backend = Tdbsam # Passdb backend (user backend), Samba has three user backgrounds: smbpasswd, Tdbsam, and Ldapsam.

which

(1) SMBPASSWD:

The approach is to use the SMB tool SMBPASSWD to set up a samba password for the system user (real or virtual), which the client uses to access the Samba resources. SMBPASSWD in/etc/samba, the file needs to be created manually.
cat/etc/passwd | Mksmbpasswd.sh >/etc/samba/smbpasswd

When creating a virtual user with Smbpass, you must create a system user

(2) Tdbsam:

Use a database file to create a user database. The database file is called Passdb.tdb, in/etc/samba. PASSDB.TDB user database can be used

When creating a virtual user with Smbpass, you must create a system user

SMBPASSWD-A Create Samba users, #要创建的Samba用户必须先是系统用户.

You can also create a Samba account using Pdbedit

Pdbedit a number of parameters, listed several main:
PDBEDIT-A Username: Create a new samba account.
Pdbedit-x Username: Delete Samba account.
Pdbedit-l: Lists the list of Samba users and reads the PASSDB.TDB database file.
PDBEDIT-LV: Lists the Samba user list details.
Pdbedit-c "[D]"-u username: Pauses the Samba user account.
Pdbedit-c "[]"-u username: Restores the samba user account.

(3) Ldapsam:

Authenticate users based on the LDAP account management method. First to establish the LDAP Service, set "Passdb backend = Ldapsam:ldap://ldap Server"

Load printers and cups options two parameters to set the printer-related # can generally be commented out

The hosts allow = 127. 192.168.12.192.168.13. The 172.16.# is used to set the allowed hosts, and if preceded by ";" means all hosts are allowed
Log file =/var/log/samba/%m.log #定义samba的日志, where the%m is the NetBIOS name above
Max log size = 50 # Specifies the maximum capacity of the log, in K

[Homes] This part of the content share the user's own home directory, that is, when the user logged on to the samba server is actually entered into the user's home directory, after the user login, the share name is not homes but the user's own identifier, for a simple file-sharing environment, this part can be looked out.
[Printers] This part of the content set up printer Sharing

Experiment one: Ask to share a directory, anyone can access, that is, without entering a password to access, require read-only

Its corresponding configuration file

[Global] section MyGroup change to Workgroup
Security = user changed to Security = Share

[Share]
Comment = Share all
Path =/share
browseable = yes
Public = yes
writable = no

Create a shared directory: Mkdir/share; Chmodt 777/share

Start:/ETC/INIT.D/SMB start

Test: Win Machine Browser input File://192.168.0.22/share
or run column input: \\192.168.0.22

Experiment two: Share a directory, use a user name and password to log in before you can access, requirements can read and write

[Global]
Workgroup = Workgroup
Server string = Samba Server Version%v
Security = User
Passdb backend = Tdbsam
Load printers = yes
Cups options = raw

[Share]
Comment = Share for users
Path =/share
browseable = yes
writable = yes
public = No

Create a shared directory: Mkdir/share; Chmodt 777/share

To create a system account:
Useradd user1
Useradd User2
Add User1/user2 as a Samba account:
Pdbedit-a user1
Pdbedit-a User2
List all Samba accounts: pdbedit–l
Restart Service Services SMB restart
Test: Browser Input File://192.168.0.22/share

Extensions: Files that share Samba services on Linux

(1) Installing the client software Yum install-y samba-client
Command format: smbclient//ip/share name-u user name
such as: Smbclient//127.0.0.1/share If it is anonymous access can omit-u

Can I use it after entering? View the commands you can use

(2) Installation file system Yum Install–y cifs-utils

Mount Mount Samba directory: mount-t cifs//192.168.176.253/share/mnt-o username=user1,password=123456

The host at this time in the/mnt directory to be hung to create files, found that the file permissions are Samb system users, user groups

Samba Common errors: (1) shared directory not created

(2) When you share anonymously, the configuration file public= Yes cannot be written as No

In addition, Linux can be telnet or ssh telnet to samb service end-of-pass judgment


Samba services implemented in Windows shared files

Related Article

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.