Install Samba Server

Source: Internet
Author: User
Install the Samba server-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Samba Server is a Windows File Server and printing server on Linux platform. It can be used by Windows users or Linux users and serves as a bridge between Linux and Windows. The installation command is as follows:

Debian ~ : # Apt-get install samba smbclient
Samba is a server software package, and smbclient is a client software package, which can be installed independently. The configuration file of the Samba server is named smb. conf and is located in the/etc/samba/directory. There is also an smb in the/usr/share/samba/directory. conf file backup, if you set/etc/samba/smb When configuring the server. the conf file can be used to restore to the initial state. The STARTUP script is located in the/etc/init. d/directory named samba. If you modify the smb. conf configuration file, run the samba restart command to restart the Samba server.

In the/etc/default/samba file, you can set the Startup Mode of the samba server, daemons or inetd. The default setting is daemons:

# Defaults for samba initscript
# Sourced by/etc/init. d/samba
# Installed at/etc/default/samba by the maintainer scripts
#

#
# This is a POSIX shell fragment
#

# How shocould Samba (smbd) run? Possible values are "daemons"
# Or "inetd ".
RUN_MODE = "daemons"
Disable the smbcontrol program available on the server. The command format is as follows:

Debian :~ # Smbcontrol smbd shutdown
Some settings are required to make the Samba server work properly.

Create a test user in the system

Debian ~ : # Useradd-m test
Add samba users

Debian ~ : # Smbpasswd-a test

The samba user name must be the same as the Linux user name, but the password can be different. When a user logs on to the Sabma server, the password is set using the sabpasswd program.

Modify the/etc/samba/smb. conf file and set the security level to user level. In this way, each user connecting to the Samba server must provide the user name and password. We also need to enable the encryption password function so that the systems above NT can connect to the Samba server normally. The following is a configuration file example.

#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You shoshould read
# Smb. conf (5) manual page in order to understand the options listed
# Here. Samba has a huge number of retriable options most of which
# Are not shown in this example
#
# Any line which starts with a; (semi-colon) or a # (hash)
# Is a comment and is ignored. In this example we will use #
# For commentary and a; for parts of the config file that you
# May wish to enable
#
# NOTE: Whenever you modify this file you should run the command
# "Testparm" to check that you have not found any basic syntactic
# Errors.
#

#====================================== Global Settings ==================== ==========

[Global]

# Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part
Workgroup = DEBIAN_FANS

# Server string is the equivalent of the NT Description field
Server string = % h server (Samba % v)

# Windows Internet Name Serving Support Section:
# WINS Support-Tells the NMBD component of Samba to enable its WINS Server
; Wins support = no

# WINS Server-Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; Wins server = w. x. y. z

# This will prevent nmbd to search for NetBIOS names through DNS.
Dns proxy = no

# What naming service and in what order shoshould we use to resolve host names
# To IP addresses
; Name resolve order = lmhosts host wins bcast


#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# That connects
Log file =/var/log/samba/log. % m

# Put a capping on the size of the log files (in Kb ).
Max log size = 1000

# If you want Samba to only log through syslog then set the following
# Parameter to 'yes '.
; Syslog only = no

# We want Samba to log a minimum amount of information to syslog. Everything
# Shoshould go to/var/log/samba/log. {smbd, nmbd} instead. If you want to log
# Through syslog you shoshould set the following parameter to something higher.
Syslog = 0

# Do something sensible when Samba crashes: mail the admin a backtrace
Panic action =/usr/share/samba/panic-action % d


####### Authentication #######

# "Security = user" is always a good idea. This will require a Unix account
# In this server for every user accessing the server. See
#/Usr/share/doc/samba-doc/htmldocs/ServerType.html in the samba-doc
# Package for details.
Security = user

# You may wish to use password encryption. See the section on
# 'Encryption password' in the smb. conf (5) manpage before enabling.
Encrypt passwords = yes

# If you are using encrypted passwords, Samba will need to know what
# Password database type you are using.
Passdb backend = tdbsam guest

Obey pam restrictions = yes

; Guest account = nobody
Invalid users = root

# This boolean parameter controls whether Samba attempts to sync the Unix
# Password with the SMB password when the encrypted SMB password in
# Passdb is changed.
; Unix password sync = no

# For Unix password sync to work on a Debian GNU/Linux system, the following
# Parameters must be set (thanks to Augustin Luton
# Sending the correct chat script for the passwd program in Debian Potato ).
Passwd program =/usr/bin/passwd % u
Passwd chat = * Enter \ snew \ sUNIX \ spassword: * % n \ n * Retype \ snew \ sUNIX \ spassword: * % n \ n.

# This boolean controls whether PAM will be used for password changes
# When requested by an SMB client instead of the program listed in
# 'Passwd program '. The default is 'no '.
; Pam password change = no


########## Printing ##########

# If you want to automatically load your printer list rather
# Than setting them up individually then you'll need this
; Load printers = yes

# Lpr (ng) printing. You may wish to override the location of
# Printcap file
; Printing = bsd
; Printcap name =/etc/printcap

# CUPS printing. See also the cupsaddsmb (8) manpage in
# Cupsys-client package.
; Printing = cups
; Printcap name = cups

# When using [print $], root is implicitly a 'printer admin', but you can
# Also give this right to other users to add drivers and set printer
# Properties
; Printer admin = @ ntadmin


######## File sharing ########

# Name mangling options
; Preserve case = yes
; Short preserve case = yes


########### Misc ############

# Using the following line enables you to customise your configuration
# On a per machine basis. The % m gets replaced with the netbios name
# Of the machine that is connecting
; Include =/home/samba/etc/smb. conf. % m

# Most people will find that this option gives better performance.
# See smb. conf (5) and/usr/share/doc/samba-doc/htmldocs/speed.html
# For details
# You may want to add the following on a Linux system:
# SO_RCVBUF = 8192 SO_SNDBUF = 8192
Socket options = TCP_NODELAY

# The following parameter is useful only if you have the linpopup package
# Installed. The samba maintainer and the linpopup maintainer are
# Working to installation and configuration of linpopup and samba.
; Message command =/bin/sh-c '/usr/bin/linpopup "% f" "% m" % s; rm % s '&

# Domain Master specifies Samba to be the Domain Master Browser. If this
# Machine will be configured as a BDC (a secondary logon server), you
# Must set this to 'no'; otherwise, the default behavior is recommended.
; Domain master = auto

# Some defaults for winbind (make sure you're not using the ranges
# For something else .)
; Idmap uid = 10000-20000
; Idmap gid = 10000-20000
; Template shell =/bin/bash

#==================================== Share Definitions ====================== ==========

[Homes]
Comment = Home Directories
Browseable = yes

# By default, the home directories are exported read-only. Change next
# Parameter to 'yes' if you want to be able to write to them.
Writable = no

# File creation mask is set to 0700 for security reasons. If you want
# Create files with group = rw permissions, set next parameter to 0775.
Create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want
# Create dirs. with group = rw permissions, set next parameter to 0775.
Directory mask = 0700

# Un-comment the following and create the netlogon directory for Domain Logons
# (You need to configure Samba to act as a domain controller too .)
; [Netlogon]
; Comment = Network Logon Service
; Path =/home/samba/netlogon
; Guest OK = yes
; Writable = no
; Share modes = no

[Printers]
Comment = All Printers
Browseable = no
Path =/tmp
Printable = yes
Public = no
Writable = no
Create mode = 0700

# Windows clients look for this share name as a source of downloadable
# Printer drivers
[Print $]
Comment = Printer Drivers
Path =/var/lib/samba/printers
Browseable = yes
Read only = yes
Guest OK = no
# Uncomment to allow remote administration of Windows print drivers.
# Replace 'ntadmin' with the name of the group your admin users are
# Members.
; Write list = root, @ ntadmin

# A sample share for sharing your CD-ROM with others.
; [Cdrom]
; Comment = Samba server's CD-ROM
; Writable = no
; Locking = no
; Path =/cdrom
; Public = yes

# The next two parameters show how to auto-mount a CD-ROM when
# Cdrom share is accesed. For this to work/etc/fstab must contain
# An entry like this:
#
#/Dev/cd0/cdrom iso9660 ults, noauto, ro, user 0 0
#
# The CD-ROM gets unmounted automatically after the connection to
#
# If you don't want to use auto-mounting/unmounting make sure the CD
# Is mounted on/cdrom
#
; Preexec =/bin/mount/cdrom
; Postexec =/bin/umount/cdrom

[D]
Writable = yes
Path =/mnt/hda5
Valid users = root # specify a valid user. Only the root user can access the shared directory.
Create mask = 0660
Directory mask = 0770
In this way, the most basic Samba server is set up. On Windows, you can use the test user name to access the/home/test directory on the Samba server. We also set a shared Directory d, pointing to the local/mnt/hda5 directory. This share can only be accessed by the root user. Of course, like the test user, you must use the smbpasswd-a root command to create a samba user named root before connection. In Linux, we can use the smbclient/samba_server/sharename command to access the samba server shared directory.

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.