Монтирование сетевых ресурсов pam_mount
На примере(Astra, Debian, Ubuntu)
Требуется выполнить несколько простых шагов:
1. Установить на рабочую станцию два пакета: libpam-mount и cifs-utils
2. Отредактировать конфигурационные файлы в каталогах /etc/pam.d и /etc/security, создать каталог, куда будем монтировать.
Итак, начальные условия:
Рабочая станция под управлением ОС на базе ядра linux (в данном конкретном случае введена в домен Active Directory(AD)).
В локальной сети существует, настроен и функционирует файловый сервер с именем ad, предоставляющий ресурсы, сетевой каталог с именем dfs (все имена выбраны как пример) по протоколу SMB/CIFS, также заведённый в домен и использующий ACL для назначения пользователям прав доступа к ресурсам.
Выполним первый шаг, установим необходимые пакеты командой:
$sudo apt install libpam-mount cifs-utils
Далее приступаем ко второму шагу, выполнив команду:
$nano /etc/pam.d/common-auth
В конфигурационном файле проверяем наличие строчки:
auth optional pam_mount.so
Если строчка отсутствует ее не обходимо добавить
#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
# traditional Unix authentication mechanisms.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
# local modules either before or after the default block, and use
# pam-auth-update to manage selection of other modules. See
# pam-auth-update(8) for details.
# here are the per-package modules (the "Primary" block)
auth [success=5 default=ignore] pam_krb5.so minimum_uid=1000
auth [success=4 default=ignore] pam_unix.so nullok_secure try_first_pass
auth [success=3 default=ignore] pam_winbind.so krb5_auth krb5_ccache_type=FILE cached_login try_first_pass
auth [success=2 default=ignore] pam_ccreds.so minimum_uid=1000 action=validate use_first_pass
auth [default=ignore] pam_ccreds.so minimum_uid=1000 action=update
# here's the fallback if no module succeeds
auth requisite pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth required pam_permit.so
# and here are more per-package modules (the "Additional" block)
auth optional pam_ccreds.so minimum_uid=1000 action=store
auth optional pam_cap.so
auth optional pam_mount.so
# end of pam-auth-update config
$nano /etc/pam.d/common-session
В конфигурационном файле проверяем наличие строчки:
session optional pam_mount.so
Если строчка отсутствует ее не обходимо добавить
#
# /etc/pam.d/common-session - session-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define tasks to be performed
# at the start and end of sessions of *any* kind (both interactive and
# non-interactive).
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
# local modules either before or after the default block, and use
# pam-auth-update to manage selection of other modules. See
# pam-auth-update(8) for details.
# here are the per-package modules (the "Primary" block)
session [default=1] pam_permit.so
# here's the fallback if no module succeeds
session requisite pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
session required pam_permit.so
# The pam_umask module will set the umask according to the system default in
# /etc/login.defs and user settings, solving the problem of different
# umask settings with different shells, display managers, remote sessions etc.
# See "man pam_umask".
session optional pam_umask.so
# and here are more per-package modules (the "Additional" block)
session optional pam_krb5.so minimum_uid=1000
session required pam_unix.so
session optional pam_winbind.so
session optional pam_mount.so
session optional pam_systemd.so
session optional pam_mkhomedir.so skel=/etc/skel/ umask=0077
# end of pam-auth-update config
Создаём каталог, который будет точкой монтирования ресурсов:
mkdir /mnt/share
Осталось отредактировать файл в каталоге /etc/security (pam_mount.conf.xml). Редактируем (только секция volume definitions):
nano /etc/security/pam_mount.conf.xml
<!-- Volume definitions -->
<volume fstype="cifs" server="ad" path="dfs" mountpoint="/mnt/share" options="user,owner,noexec,iocharset=utf8,rw" />
<!-- pam_mount parameters: General tunables -->
Перезагружаемся, входим под пользователем, кому доступен данный ресурс и проверяем каталог /mnt/share.