Настройка на Samba в Debian

Настройки свързвани с конфигуриране на вътрешна мрежа и Интернет.

Модератори: Freya, Kulu Ngile

Настройка на Samba в Debian

Мнениеот Kulu Ngile » Сря 20, Сеп, 2006 16:13

Какво е Samba?
Samba е комплект от приложения, които комуникират със SMB (Server Message Block) протокола. Много операционни системи, включително Windows и ОС/2, използват SMB за изпълняване на клиент-сървър мрежата. С поддръжката на този протокол, Samba позволява на Unix сървърите да влизат в действие, да комуникират със същият мрежов протокол, който ползва и Windows

Samba пакета в Дебиан
Този пакет съдържа всички нужни компоненти за включването на вашият Debian GNU/Linux към мощният file and printer сървър.

Обикновено, Samba пакетите в Дебиан са:

- samba - като file and printer сървър в Unix
- samba-common – използва се и от сървъра и клиента
- smbclient – лесен клиент за Unix.
- swat - Samba Web Administration Tool
- samba-doc – документацията на Samba
- smbfs - Mount и umount команди за smbfs (kernels 2.2.x и нагоре).
- libpam-smbpass - pluggable модул за автентичност за SMB password database
- libsmbclient – Споделени библиотеки, които разрешават на приложенията да комуникират със SMB сървъра
- libsmbclient-dev - libsmbclient shared libraries
- winbind: Уаслуга за анализиране на потребите и групи от Windows NT сървъри
- python2.3-samba

Не е нужно да ги инсталирате всичките, а само тези, които отговарят на нуждите ви. Примерно, за да имате достъп до други SMB сървъри, вие може да инсталирате само smbclient и samba-common


Инсталиране на Samba в Дебиан
Код за потвърждение: Избери целия код
apt-get install samba samba-common samba-doc libcupsys2-gnutls10 libkrb53 winbind smbclient

Ще ви бъдат зададени някои основни въпроси свързани с конфигурацията на samba-та, като например за workgroup или domain и т.н.

Задаваме има на хоста и неговото IP
- редактираме /etc/hosts
Код за потвърждение: Избери целия код
127.0.0.1       localhost.localdomain   localhost       aku
192.168.0.100   samba.example.com     aku


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

- задаваме hostname
Код за потвърждение: Избери целия код
echo samba.example.com > /etc/hostname
/bin/hostname -F /etc/hostname


Инсталиране на quota
Код за потвърждение: Избери целия код
apt-get install quota

Променяте в /etc/fstab опциите при монтирането на / и /home, като добавите userquota и grpquota, т.е. трябва да ви изглежда така
Код за потвърждение: Избери целия код
/dev/hdaX       /               ext3    defaults,errors=remount-ro,usrquota,grpquota 0       1
/dev/hdaX1       /home            ext3    defaults,usrquota,grpquota        0       2

където:
-hdX e root дяла ви
-hdX1 е /home дяла ви
След това изпълняваме
Код за потвърждение: Избери целия код
touch /quota.user /quota.group
chmod 600 /quota.*
mount -o remount /
touch /home/quota.user /home/quota.group
chmod 600 /home/quota.*
mount -o remount /home
quotacheck -avugm
quotaon -avug


Подготовка на директориите и потребителите
Код за потвърждение: Избери целия код
mkdir /home/samba
mkdir /home/samba/netlogon
mkdir /home/samba/profiles
mkdir /var/spool/samba
chmod 777 /var/spool/samba/
chown -R root:users /home/samba/
chmod -R 771 /home/samba/

Сега трябва да се създадем потребител, който да има достъп до тази директория, както и администратор
Код за потвърждение: Избери целия код
useradd ngile -m -G users

Задаваме парола на този потребител
Код за потвърждение: Избери целия код
smbpasswd –a ngile
smbpasswd –a root
echo "root = Administrator" >/etc/samba/smbusers


Създаване на споделение директории
Код за потвърждение: Избери целия код
mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
chmod -R ug+rwx,o+rx-w /home/shares/allusers/


Променяме реда hosts на /etc/nsswitch.conf да изглежда така
Код за потвърждение: Избери целия код
hosts: files wins dns


Задаваме IP-та, които ще имат достъп до Samba във файла /etc/hosts
Код за потвърждение: Избери целия код
192.168.0.10 aku
192.168.0.11 debian


Настройка на конфигурационният файл на samba
Конфигурационният файл се намира в /etc/samba/smb.conf. В този файл, главната секция е Global, в която се дефинират всички параметри. Примерно
Код за потвърждение: Избери целия код
[global]
   workgroup = DEBIAN
   netbios name = AKU
   server string = %h server (Samba, Debian)


   passdb backend = tdbsam
   security = user
   username map = /etc/samba/smbusers
   name resolve order = wins bcast hosts
   domain logons = yes
   preferred master = yes
   wins support = yes

   # Set CUPS for printing
   printcap name = CUPS
   printing = CUPS

   # Default logon
   logon drive = H:
#   logon script = scripts/logon.bat
   logon path = \\server1\profile\%U


   # Useradd scripts
   add user script = /usr/sbin/useradd -m %u
   delete user script = /usr/sbin/userdel -r %u
   add group script = /usr/sbin/groupadd %g
   delete group script = /usr/sbin/groupdel %g
   add user to group script = /usr/sbin/usermod -G %g %u
   add machine script = /usr/sbin/useradd -s /bin/false/ -d /var/lib/nobody %u
   idmap uid = 15000-20000
   idmap gid = 15000-20000


   # sync smb passwords woth linux passwords
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
   passwd chat debug = yes
   unix password sync = yes

   # set the loglevel
   log level = 3
[homes]
   comment = Home
   valid users = %S
   read only = no
   browsable = no


[printers]
   comment = All Printers
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   browsable = no


[netlogon]
   comment = Network Logon Service
   path = /home/samba/netlogon
   admin users = Administrator
   valid users = %U
   read only = no


[profile]
   comment = User profiles
   path = /home/samba/profiles
   valid users = %U
   create mode = 0600
   directory mode = 0700
   writable = yes
   browsable = no
[allusers]
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes


За да проверим конфигурационият файл дали е правилен, трябва да изпълниме следната команда:
Код за потвърждение: Избери целия код
testparm

За да влезнат промените в сила, трябва да рестартираме samba-та, т.е.
Код за потвърждение: Избери целия код
/etc/init.d/samba restart

Ако искате да прибавите повече опции в конфигурационият файл, може да прочетете man page на smb.conf

Проверка на конфигурацията на samba
Ако искаме да проверим дали конфигурацията на samba-та с потребител ngile е правилна, трябва да изпълним
Код за потвърждение: Избери целия код
smbclient -L //aku -U%

Трябва да видите нещо подобно на
Код за потвърждение: Избери целия код
red@debian:~$ smbclient -L //aku -U kulu
Password:
Domain=[DEBIAN] OS=[Unix] Server=[Samba 3.0.14a-Debian]

        Sharename       Type      Comment
        ---------       ----      -------
        netlogon        Disk      Network Logon Service
        allusers        Disk      All Users
        IPC$            IPC       IPC Service (samba server (Samba, Debian))
        ADMIN$          IPC       IPC Service (samba server (Samba, Debian))
        kulu            Disk      Home
Domain=[DEBIAN] OS=[Unix] Server=[Samba 3.0.14a-Debian]

        Server               Comment
        ---------            -------
        AKU                  samba server (Samba, Debian)

        Workgroup            Master
        ---------            -------
        DEBIAN



Задаване на подразбиращата се домейн група за Windows
Код за потвърждение: Избери целия код
net groupmap modify ntgroup="Domain Admins" unixgroup=root
net groupmap modify ntgroup="Domain Users" unixgroup=users
net groupmap modify ntgroup="Domain Guests" unixgroup=nogroup


Настройка на Windows
Трябва да се автентикира всяка работна машина, т.е. всеки Windows, който ще се връзва към SMB. Това става като се логнете с всеки user, който има административни привилегии и
[Windows 2000] Start -> Settings -> Control Panel -> System -> Network Identification -> Properties -> Member of -> Domain ->тука пишем domain name, което сме записали в 'workgroup' секцията на smb.conf (в нашият случай debian)-> ok
Въведете root username и password за фаиловият Samba сървър.

Източник: Основен
Последна промяна Kulu Ngile на Съб 25, Ное, 2006 17:20, променена общо 1 път
Ако съдбата е срещу теб, толкова по-зле за нея.

Изображение
APT HOWTO
Kulu Ngile
Унуфри
 
Мнения: 1233
Регистриран на: Съб 04, Мар, 2006 2:04
Местоположение: София

Мнениеот Lord_Veidar » Чет 12, Окт, 2006 21:39

Ами имам някакакъв проблем .
Eто какво пише в /etc/samba/smb.conf.

Код за потвърждение: Избери целия код
 Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable 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 a #
# 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 many any basic syntactic
# errors.
#

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

[global]

## Browsing/Identification ###

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

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

# 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 should 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
# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
# through syslog you should 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
# 'encrypt passwords' in the smb.conf(5) manpage before enabling.
   encrypt passwords = true

# 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 the
# 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 <aluton> for
# 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 the
# printcap file
;   printing = bsd
;   printcap name = /etc/printcap

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# 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 ease 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 =======================

wins support = no
[homes]
   comment = Home Directories
   browseable = no

# 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 to
# 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 to
# 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 of.
;   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 the
#   cdrom share is accesed. For this to work /etc/fstab must contain
#   an entry like this:
#
#       /dev/scd0   /cdrom  iso9660 defaults,noauto,ro,user   0 0
#
# The CD-ROM gets unmounted automatically after the connection to the
#
# 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


[veidar]
path = /home/cveti/muzika/filmi
comment = dieeee
available = yes
browseable = yes
public = yes
writable = no


А ето какво става , когато напеша ;
Код за потвърждение: Избери целия код
smbclient -L //debianserver -U veidar


ми излиза следното ;
Код за потвърждение: Избери целия код
Connection to debianserver failed
Lord_Veidar
Участник
 
Мнения: 35
Регистриран на: Вто 05, Сеп, 2006 19:24

Мнениеот Kulu Ngile » Пет 13, Окт, 2006 17:57

1. workgroup ти е MSHOME, а не debianserver
Код за потвърждение: Избери целия код
smbclient -L //MSHOME -U veidar


2. Нямаш нито guest акаунт разрешен, нито валиден потребител. Във вторият случай
Код за потвърждение: Избери целия код
valid users = veidar
admin users = debian

или както ти се казва samba user-a. Разгледай основната настройка, която аз съм дал и я сравни с твоята.

Успех
Ако съдбата е срещу теб, толкова по-зле за нея.

Изображение
APT HOWTO
Kulu Ngile
Унуфри
 
Мнения: 1233
Регистриран на: Съб 04, Мар, 2006 2:04
Местоположение: София

Мнениеот Kulu Ngile » Съб 25, Ное, 2006 17:23

Промених доста неща, а и остана да се настрой CUPS. Малко по-натам, ще оптимизирам статията още по-добре. Ето и какво сътворихме тук и тук
Ако съдбата е срещу теб, толкова по-зле за нея.

Изображение
APT HOWTO
Kulu Ngile
Унуфри
 
Мнения: 1233
Регистриран на: Съб 04, Мар, 2006 2:04
Местоположение: София

Мнениеот Centrino » Чет 05, Апр, 2007 8:23

Как да деинсталирам Samba ?
Изображение
Аватар
Centrino
Участник
 
Мнения: 34
Регистриран на: Сря 14, Мар, 2007 21:08
Местоположение: Разград

Мнениеот Kulu Ngile » Нед 08, Апр, 2007 16:41

aptitude remove samba
rm -rf /etc/samba
update-rc.d -n -f samba remove
Ако съдбата е срещу теб, толкова по-зле за нея.

Изображение
APT HOWTO
Kulu Ngile
Унуфри
 
Мнения: 1233
Регистриран на: Съб 04, Мар, 2006 2:04
Местоположение: София

Съобщения за грешка ...

Мнениеот Стефан Радев » Пон 01, Окт, 2007 17:46

При изпълнение на указанията в статията се получиха грешките по-долу. Какво означават и трябва ли да ме притесняват?
Код за потвърждение: Избери целия код
debian-server:~# quotacheck -avugm
quotacheck: WARNING - Quotafile //quota.user was probably truncated. Cannot save quota settings...
quotacheck: WARNING - Quotafile //quota.group was probably truncated. Cannot save quota settings...
quotacheck: Scanning /dev/sda1 [/] done
quotacheck: Checked 2448 directories and 37728 files
quotacheck: WARNING - Quotafile /home/quota.user was probably truncated. Cannot save quota settings...
quotacheck: WARNING - Quotafile /home/quota.group was probably truncated. Cannot save quota settings...
quotacheck: Scanning /dev/mapper/ata--raid1-home [/home] done
quotacheck: Checked 4 directories and 7 files

И малко по-долу:
Kulu Ngile написа:Подготовка на директориите и потребителите
Код:
...
mkdir /var/spool/samba
chmod 777 /var/spool/samba/
...

А при мен (без да съм изпълнявал тези стъпки):
Код за потвърждение: Избери целия код
debian-server:~# ls -la /var/spool/
total 32
...
drwxrwxrwt  2 root        root        4096 2007-05-30 12:53 samba
...
Човек и добре да живее... нали? :)
Стефан Радев
Участник
 
Мнения: 7
Регистриран на: Чет 04, Яну, 2007 13:00
Местоположение: София

Мнениеот Kulu Ngile » Пон 01, Окт, 2007 21:16

Код за потвърждение: Избери целия код
[debian Desktop]# quotacheck -avugm
quotacheck: WARNING - Quotafile //quota.user was probably truncated. Cannot save quota settings...
quotacheck: WARNING - Quotafile //quota.group was probably truncated. Cannot save quota settings...
quotacheck: Scanning /dev/hda3 [/] done
quotacheck: Checked 21566 directories and 243634 files

Код за потвърждение: Избери целия код
[debian Desktop]# quotaon -avug
/dev/hda3 [/]: group quotas turned on
/dev/hda3 [/]: user quotas turned on

Код за потвърждение: Избери целия код
[debian Desktop]# quotacheck -avugm
quotacheck: Scanning /dev/hda3 [/] done
quotacheck: Checked 21566 directories and 243634 files
[debian Desktop]#

т.е. само при първото зареждане са Warning-те :)
Ако съдбата е срещу теб, толкова по-зле за нея.

Изображение
APT HOWTO
Kulu Ngile
Унуфри
 
Мнения: 1233
Регистриран на: Съб 04, Мар, 2006 2:04
Местоположение: София


Назад към Мрежови настройки

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 1 госта

cron