Samba file sharing service

Source: Internet
Author: User

Samba file sharing service

I,SambaSoftware Package Installation
Samba-3.0.33-3.28.e15.i386.rpm // Service Pack
Samba-client-3.0.33-3.28.e15.i386.rpm // client package
Samba-common-3.0.33-3.28.e15.i386.rpm // public package
Samba-swat-3.0.33-3.28.e15.i386.rpm // web package
Note: Check whether the above software package is installed. If the package is missing, install it.
[Root @ localhost ~] # Rpm-qa | grep "^ samba"

II,SambaService program components
Note: The Samba server provides two service programs, smbd and nmdb, with different functions.
Smbd --- access to shared resource directories and files in the service provided by the client;
Nmbd --- Responsible for providing host name resolution based on the NetBLOS protocol for windows Host query Server
[Root @ localhost ~] # Service smb start // start the Samba service
[Root @ localhost ~] # Netstat-natup | grep "mbd" // query the service port

III,Main configuration fileSmb. conf
Note: common configuration items and descriptions of Samba servers.
Workgroup: Set the name of the change group where the server is located.
Server string sets the description and description of the server.
Security sets the security level of the server, which can be set to one of the following four: share (Anonymous
The user must be verified by the server.
One server to verify the user name and password), domain is controlled by the windows domain Controller
Verify the user name and password)
Log file: Set the log file of the Samba server. The default value is/var/log/samba/% m. log.
Create a log file by each client. The % m variable indicates the client name or ip address.
Comment sets comments for the corresponding shared directory to describe the information
Path: Specifies the file path of the shared directory on the server.
Browseable: sets whether the shared directory is visible in "Network Neighbor". If it is set to No, the directory is hidden.
Guest OK sets whether all users can access the shared directory, which is the same as the public configuration item.
Writable sets whether the shared directory is writable, which is opposite to the read only configuration item.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0545015030-0.jpg "title =" 12.jpg" alt = "181402932.jpg"/>

Build a file sharing Server
1) Sharing with Anonymous Access
Note: Anonymous Access sharing applies to public resource sharing. Generally, read-only access is recommended.
When anonymous sharing is set, you can adjust it in the main configuration file smb. conf,
1. Change the default level to share. 2. Add a shared directory configuration.
# For example, publish the local mounted CD directory/media/cdrom/to share the file named rhel5
[Root @ localhost ~] # Mount/dev/cdrom/media/cdrom // mount the disc
[Root @ localhost ~] # Vim/etc/samba/smb. conf
[Global]
Workgroup = WORKGROUP // use windows Host default workgroup
Security = share // anonymous access is allowed by default
..... // Other modifications as required
[Rhel5]
Comment = RHEL 5.5 DVDdirectory // description
Path =/media/cdrom // shared directory path
Public = yes // accessible to all users
Read only = yes // read-only permission
[Root @ localhost ~] # Service smb restart

(2 ),Share that requires user verification
Note: When setting shared files for user authentication, it is also required in the main configuration file smb. conf.
Change the default security level to user, and add
Shared directory configuration, specifying user permissions. Before that, you must create an authorization sharing
Account.
1.Set User Access Authorization
# Create a shared user vina lisi to confirm the shared directory
[Root @ localhost ~] # Useradd vina // create a system user vina
[Root @ localhost ~] # Useradd lisi // create a system user lisi
[Root @ localhost ~] # Pdbedit-a-u vina // Add a shared user vina
[Root @ localhost ~] # Pdbedit-a-u lisi // Add a shared user lisi
[Root @ localhost ~] # Mkdir/abc // create a local test directory

# Modify the smb. conf configuration file and add the shared directory configuration segment named [abc]
[Root @ localhost ~] # Vim/etc/samba/smb. conf
[Global]
Security = user
.... //
[Abc]
Comment = abc // description
Path =/abc // path of the shared directory
Read only = no // not writable
Public = no // not all users can access
Valid users = vina, lisi // valid user or group @ group name
Write list = lisi // Writable User
[Root @ localhost ~] # Service smb restart
2.Confirm Directory Access Authorization
[Root @ localhost ~] # Chmod 777/abc/
Note: In addition to user authorization, you also need to set the files to be uploaded and create sub-Directories
Default permission,
[Root @ localhost ~] # Vim/etc/samba/smb. conf
[Abc]
Directory mask = 0755 // upload directory permission
Create mask = 0644 // default File Permission
[Root @ localhost ~] # Service smb restart

[Root @ localhost ~] # Pdbedit-L // list all Samba shared users
[Root @ localhost ~] # Pdbedit-x-u vina // Delete Samba users

User ing and access address restrictions

I,Share account ing alias)
Note: the Samba ing file of the samba shared account is located in/etc/Samba/smbusers. Add a record after the file.
Format: Shared username = alias 1 alias 2 ....
[Root @ localhost ~] # Vim/etc/samba/smbusers
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0545011H4-1.jpg "title =" 7.jpg" alt = "1818220.5.jpg"/>

Note: After configuring the alias record, you need to modify the main configuration file,
Add [global]
Username map =/etc/samba/smbusers
[Root @ localhost ~] # Servi ce smb restart

II,Access address Restriction
For clients accessing the Samba server,Hosts allow","Hosts deny"Configuration item
Access restrictions are generally applied to the [global] global configuration section, or to a shared configuration segment. The restriction object can enable the host name, IP address, or network segment address (saving the host part). Multiple addresses are separated by commas or spaces.
[Root @ localhost ~] # Vim/etc/samba/smb. conf
[Global]
Hosts allow = 192.168.1. // allow this network segment address
[Root @ localhost ~] # Service smb restart


Access Shared Folders

I,UseSmbclientAccess Shared Files
1 ).Query the shared resource list of the target host.
[Root @ localhost ~] # Smbclient-L 192.168.1.1 // query shared resources on this ip host
2 ).Anonymous Access to folder Login
[Root @ localhost ~] # Smbclient // 192.168.1.1/abc // login to a folder that can be accessed anonymously
3 ).User Authentication folder login Method
[Root @ localhost ~] # Smbclient-U username // 192.168.1.1/toot
Smb: \> pwd // view the current working path
Smb: \> ls // list content in the current directory
Smb: \> LCD/root // switch the local directory to/root/
Smb: \> cd abc // switch to the abc subdirectory of the shared directory
Smb: \ abc \> mget test.txt // download the test.txt File
Smb: \ abc \> quit // exit the shared directory
[Root @ localhost ~] # Ls/root/test.txt // confirm the downloaded file
4).Use mountMount Shared Folders
Note: The smbclinet tool can easily log on to the samba server, but only after downloading to a Local Machine
To view the file content. Use the mount tool to mount the shared file to the local device
To directly use the contents of the shared folder.
[Root @ localhost ~] # Mount-o username = username // 192.168.1.1/toot/mnt
[Root @ localhost ~] # Cd/mnt // directly operate


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.