1. Preparations before installation 1. Use the Samba server to enable the following ports in the firewall: UDP137UDP138TCP139TCP445vi/etc/sysconfig/iptables # Configuration
I. Preparations before installation
1. To use the Samba server, the firewall must open the following ports:
TCP 137
TCP 138
TCP/IP 139
TCP/IP 445
Vi/etc/sysconfig/iptables # configure the firewall port
-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
/Etc/rc. d/init. d/iptables restart # restart the firewall to make the rule take effect.
2. Disable SELinux
Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq save, close.
Shutdown-r now restart the system.
Ii. Install Samba
1. Check whether the Samba service package is installed.
Rpm-qa | grep samba
Samba-winbind-clients-3.5.4-68.el6.i686
Samba4-libs-4.0.0-23.alpha11.el6.i686
Samba-common-3.5.4-68.el6.i686
Samba-client-3.5.4-68.el6.i686
It indicates that samba has been installed. If it is not installed, run the followingCommandInstall
Yum install samba
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
2. Configure samba
Chkconfig smb on # Set Automatic startup of Samba upon startup
Service smb start # start the Samba service
Chkconfig nmb on # Set Samba alias service to automatically start
Service nmb start # start the Samba alias service
/Etc/init. d/smb restart # restart
/Etc/init. d/smb stop # stop
/Etc/init. d/nmb restart # restart
/Etc/init. d/nmb stop # stop
Backup: cp/etc/samba/smb. conf/etc/samba/smb. confbak
Recovery: cp/etc/samba/smb. confbak/etc/samba/smb. conf
Vi/etc/samba/smb. conf
[Global] # Find this line (global Setting label) and add the following line below this line:
Workgroup = WORKGROUP # change the name of the workgroup to the name defined by the Windows network.
Server string = Samba Server # Set the Host Name of the samba server
Security = user # Set the samba server security level to user, that is, access by account and password
Netbios name = SambaServer # Set the Samba server access alias
# Add the following custom content at the end of the configuration file
[SambaServer] # Name of the shared directory displayed in the Windows Network Neighbor
Comment = SambaServer # remarks about the shared directory seen in the Windows Network neighbors
Path =/home/SambaServer # location of the shared directory in the system
Public = no # do not disclose Directories
Writable = yes # The shared directory can be read and written.
Valid users = SambaServer # Only SambaServer users are allowed to access
Save Configuration
3. Add the account SambaServer for accessing the linux shared directory
The user's home directory is/home/SambaServer, and the user's logon terminal is set to/bin/false (even if the user cannot log on to the system)
Cd/home # enter the/home Directory
Mkdir SambaServer # create a SambaServer folder
Touch samba.txt upload creates the test file samba.txt
Useradd SambaServer-d/home/SambaServer-s/bin/false
Chown SambaServer: SambaServer/home/SambaServer-R
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
4. Add the user SambaServer to the Samba user database, and set the logon password to 123456 for the shared directory.
Smbpasswd-a SambaServer
New SMB password: enter the password used by the user to log on to Samba.
Retype new SMB password: confirm the password again
Added user SambaServer.
# Note: The password set here is the password used to log on to the Samba shared directory. It is not the password used to log on to linux.
5. Restart the Samba server.
/Etc/init. d/smb restart
6. Enter
\ Ip
Or
\ SambaServer # server alias
Enter the account SambaServer password 123456.
You can access the shared directory.
So far, CentOS 6.0 linux samba server configuration is complete.
» Link to this article: http://www.osyunwei.com/archives/679.html