RussianLDP Рейтинг@Mail.ru
WebMoney: 
WMZ Z294115950220 
WMR R409981405661 
WME E134003968233 
Visa 
4274 3200 2453 6495 

Файловый сервис и печать через Samba

Linux может предоставлять сервисы SMB (то есть, сетевое разделение файлов и принтеров в WfW, Win95 и NT), используя пакет Samba. Здесь рассказывается как настроить разделение и обеспечить доступ с клиентских машин.

Пакет Samba включен в Red Hat, Вы можете установлен ли он, и какую версию Вы имеете:

rpm -q samba

Если не установлен, поставьте, используя утилиту RPM (см. подробности в разделе Использование Red Hat Package Manager (RPM) главы 10).

Наиболее важные файлы Samba:

/etc/smb.conf

Файл настроек Samba. Здесь заданы разделяемые ресурсы и прочие параметры (см. ниже)

/var/log/samba/

Расположение файла протокола для Samba

/home/samba/

Здесьрасположены совместно используемые файлы. Однако, Вы можете сменить расположение. Лично я монтирую раздел на /archive/ и располагаю файлы там.

Файл ``/etc/smb.conf'' хранит настройки разделяемых ресурсов. Первые строки содержат глобальные директивы настройки, общие для всех ресурсов (если они не отменены для конкретного ресурса), затем идет настройка каждого ресурса.

В пакет Samba входит файл smb.conf со значениями по умолчанию, который часто вполне пригоден, и нуждается лишь в небольших поправках.

В приводимом ниже примере я попробую показать Вам некоторые из наиболее важных и интересных параметров:

# Items common to all shares (unless over-ridden on a per-share basis)
[global]
   # Number of minutes of inactivity before client is disconnected
   # to avoid consuming resources.  Most clients will automatically
   # reconnect so this is a good idea to enable.
   dead time = 10

   # Don't let users connect as “root”, just-in-case.  :-)
   invalid users = root

   # Specify the account for guest shares (shares that don't require
   # a password to connect to.  This username must be a valid user
   # in the /etc/passwd file.
   guest account = guest

   # Specify where log files should be written to.  The “%m” suffix
   # means that log files will be created in the format
   # log.machine-name (eg. “log.twixel”)
   log file = /usr/local/samba/logs/log.%m

   # Maximum size of log file, in Kilobytes.
   max log size = 1000

   # Password level 3 means that case is not an issue when entering
   # passwords.  A little less secure than level 1 or 2 would be,
   # but seems to be a fair compromise for user convenience.
   password level = 3

   # Specify that all shares should appear in the browse list
   # (override any you don't want on a per-share basis).
   browseable = yes

   # If this is enabled, you can see active connections using the
   # “smbstatus” command.
   status = yes

   # The level of debugging information that is recorded in the log
   # files.  Higher values generate more information (which is
   # probably not very useful, most of the time).
   debug level = 2

   # This will send any Windows-style “POPUP” messages received on
   # the server to the postmaster by e-mail.  Not very useful, but
   # an interesting demonstration of what can be accomplished.
   message command = /bin/mail -s 'Message from %f on %m' postmaster < %s; rm %s &

   # This is a form of caching that, when enabled, may improve
   # performance when reading files.
   read prediction = true

   # A list of services that should be added automatically to the
   # browse-list.
   auto services = cdrom

   # The location of your “printcap” file, a text file containing
   # definitions for your printers.
   printcap name = /etc/printcap

   # If enabled all printers in the /etc/printcap file will be
   # loaded into the browse-list.
   load printers = yes

   # The print command by which data is spooled to a printer under Linux.
   print command = lpr -r -P%p %s

   # The print command by which job queue information (printer status)
   # can be obtained.
   lpq command = lpq -P%p

   # The print command by which unwanted print jobs can be deleted
   # from the queue.
   lprm command = lprm -P%p %j

   # The level at which Samba advertises itself for browse elections.
   # Currently set to a high value to give it an even “foot-hold” with
   # any swarmy NT servers on the network.  :-)
   os level = 34

# These are user's personal shares.  If the client's username matches on the
# server, they can access their home directory (provided they enter the
# correct password).
[homes]
   # The comments appear in the browse list.
   comment = Home Directories

   # This matches the username of the client to that of the share.
   # If they do not match, no share will be displayed in the browse
   # list, or available to connect to.
   user = %S

   # The path to the share.  For example, “smithj” would map to
   # “/home/smithj”
   path = /home/%S

   # If enabled, allow read/write access to the shares.
   writeable = yes

   # Just an inverted synonym for “writeable”. We don't *really* need
   # to use both. :-)
   readonly = no

   # Keep this disabled so that a password is required to access these
   # shares.
   public = no

   # We don't want this share (after all, it is private) to appear in
   # the browse-list of other users.
   browseable = no

# This is a publicly available print share, called “hp_laser”. It appears
# on the browse lists and can be accessed without a password by any client.
[hp_laser]
   # The comment that appears in the browse-list.
   comment = Main office printer (HP Laserjet 400)

   # The username that this share is accessed as (guest means all users).
   user = guest

   # All generated print files will first be created in the /tmp
   # directory.
   path = /tmp

   # Do not allow file creation except through print spooling.
   writeable = no

   # Set permissions accordingly -- root access to print jobs only.
   create mode = 0700

   # If this is enabled a password is not required to access the share.
   public = yes

   # This should be enabled to indicate that this is a printer share.
   printable = yes

# Here is a service providing access to the CD-ROM device.
[cdrom]
   comment = Shared CD-ROM drive on Linux
   user = guest
   path = /cdrom
   writeable = no
   read only = true
   browseable = yes
   public = yes
   guest ok = yes

Tip

Совет: Недавние версии Samba, начиная с 2.0, имеют утилиту настройки через web ``swat'', которая делает процесс намного больше дружественным. Утилита слушает TCP порт 901 Вашего сервера, так что, чтобы все настроить укажите в браузере адрес сервера и порт 901:

mydomain.name:901

(Конечно, чтобы использовать SWAT нужен запущенный web-сервер, например Apache. См. детали в разделе Администрирование Web-сервера и HTTP Proxy.)

Последние версии Samba также приобрели много дополнительных возможностей по сравнению с версиями ниже 2.0. Стоит обновить пакет.

Клиент должен иметь стек TCP/IP для соединения с разделяемыми ресурсами. Далее, для просмотра, TCP/IP должен быть привязан к NETBEUI. Под Windows 95 это может быть конфигурировано из раздела “Network” в Control Panel.

После настройки клиента, ресурсы сервера должны появиться в “Network Neighborhood” (или аналогичной системе просмотра, если используется не Windows 95/NT). Замечание переводчика: клиенты SMB доступны также под DOS, OS/2, Linux, Solaris и FreeBSD. Вы можете подсоединять сетевые диски из network neighborhood, или указывать полный путь к ресурсам (то есть, “\\mail\cdrom”). Если нужен пароль для доступа к ресурсу, он будет запрошен.

Дополнительная информация о Samba есть на Samba Home Page по адресу: http://samba.anu.edu.au/samba. Замечание переводчика: в рамках проекта Russian LDP планируется перевод документации на Samba.

Поиск

 

Найди своих коллег!