How to install and configure Samba in CentOS6.6

Source: Internet
Author: User

Install Samba

Check whether Samba is installed
# Rpm-qa | grep samba
Install Samba server and client directly through yum
# Yum-y install samba-client

Configure Samba

The main configuration file of Samba is/etc/samba/smb. conf. Here, you can log on to linux through an account under win. For complex configurations, refer to the final address. Add a shared block directly after smb. conf.

[Global]
Workgroup = WORKGROUP # workgroup [configurable]
Server string = Samba Server # set the samba server name [you can change it yourself
Netbios name = SambaServer # set the server access alias [you can change it by yourself.
Printcap name =/etc/printcap # set the path of the printer configuration file
Load printers = yes; # Allow printer sharing
Cups options = raw # The cups option is raw
; Interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
Hosts allow = 127. 192.168.12. 192.168.13.
Log file =/var/log/samba/log. % m
Max log size = 50 # The maximum log size is 50kb. If the log size is 0, no limit is imposed.
Security = user # sets the samba server security level. User: samba server verification; share: No permission verification; server: third-party host verification; domain

[Xiaosi] # Name of the shared directory displayed in the Windows network neighbor
Path =/data/www/www.woyaohuijia.cn # Shared file address
Public = no # Do not disclose directories
Writable = yes # The shared directory can be read and written.
Valid users = apache # Only apache users are allowed to access
Browseable = yes

The configuration block is indented by TAB. The copied block may contain spaces. Add a system user and add the user to the samba account

# Useradd-s/sbin/nologin smbuser
# Smbpasswd-a smbuser
# Cat/etc/passwd | mksmbpasswd. sh>/etc/samba/smbpaawd
Smbpasswd command
Smbpasswd-a adds users (the users to be added must be system users)
Smbpasswd-d: the user cannot be logged on.
Smbpasswd-e restores the user and restores the user so that the frozen user can use
Smbpasswd-n sets the user's password to null. note: If "no password" is set, to allow users to log on to the Samba server with an empty PASSWORD, the administrator must go to smb. set the following parameter in the [global] section of the conf configuration file: null passwords = yes
Smbpasswd-x delete user

Test whether the configuration is correct-testparm
Test whether the Samba settings are correct.
# Testparm-s smb. conf
# Smbclient // 192.168.5.35/public-U jck
Start Samba
View the Samba service status, start, and restart.
# Service smb status
# Service smb stop
# Service smb start
# Service smb restart
Set automatic startup of Samba service
# Chkconfig -- list | grep smb
# Chkconfig -- level 35 smb on
# Chkconfig -- level 35 nmb on
Configure firewall
# Vi/etc/sysconfig/iptables
-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-m state -- state NEW-m udp-p udp -- dport 137-j ACCEPT
-A input-m state -- state NEW-m udp-p udp -- dport 138-j ACCEPT

SELINUX configuration

# Setsebool-P samba_domain_controller on
# Setsebool-P samba_enable_home_dirs on
# Following (read-only/read-write ):
# Setsebool-P samba_export_all_ro on
# Or
# Setsebool-P samba_export_all_rw on

Use the smbmount command to remotely mount a shared directory to a local directory.
# Mkdir/public1
# Smbmount // 192.168.5.35/public1/public1-o username = jck, password = 123456
# Mount

Windows clear sharing records
After a successful connection through Samba, the logon account and password will be recorded locally. You can connect directly next time. If you need to switch the account, you can manually delete the connection records.
View access records

C: \ Users \ Administrator> net use

OK \ 192.168.5.35 \ public Microsoft Windows Network
The command is successfully completed.
Clear access records
C: \ Users \ Administrator> net use \ 192.168.5.35 \ public/delete

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.