И так стоит задача: имеется домен domainko.ru с базой (LDAP) пользователей (IP 192.168.85.140) под Windows Server 2003. Имеется уже установленный и настроенный ProFTPd сервер (IP 192.168.85.134). Необходимо настроить аутентификацию пользователей по Active Directory (LDAP) и автоматическим созданием домашних директорий в /home/ftp/pub. Систему аутентификации настроить таким образом, чтобы не осуществлять изменения в схеме LDAP. Также настроить авторизацию системных пользователей Linux (mod_auth_unix) в качестве гостевого аккаунта. Анонимный доступ необходимо закрыть.
Я не буду рассматривать подробную установку ProFTPd сервера, т.к. она проста. В нашем случае необходимо столько правильно компилировать его с модулями ldap и auth_unix. Для проверки с какими модулями скомпилирован ваш ftp сервер введите команду в строке linux:
>proftpd --list
root@linuxlo:/etc/proftpd# proftpd --list Compiled-in modules: mod_core.c mod_xfer.c mod_auth_unix.c mod_auth_file.c mod_auth.c mod_ls.c mod_log.c mod_site.c mod_delay.c mod_facts.c mod_dso.c mod_ident.c mod_auth_pam.c mod_readme.c mod_cap.c mod_ctrls.c mod_lang.c
Не удивляйтесь если модуля mod_ldap.c не будет в списке. Он подключается через include в конфигурации ftp сервера.
Рассмотрим и настроим конфигурацию модуля /etc/proftp.d/ldap.conf
------------------------------------------------------------------------------------------------------------------------------------- <IfModule mod_ldap.c>
AuthOrder mod_ldap.c mod_auth_unix.c # подключаем модуль ldap и unix
LDAPServer 192.168.85.140 # наш LDAP сервер
LDAPAttr uid SAMAccountname LDAPGenerateHomedir on # создаем домашние ftp директории пользователей LDAPGenerateHomedirPrefix /home/ftp/pub # в /home/ftp/pub CreateHome on 0755 # и назначаем chmod 755
# В данном случае все LDAP FTP пользователи располагаются в Группе (OU) People в AD. Если Вы их оставите в Users (по умолчанию где создаются AD пользователи), то необходимо заменить запись ou=people на cn=users.
LDAPDNInfo "cn=user1,ou=people,DC=domainko,DC=ru" "test" LDAPDoAuth on "ou=people,dc=domainko,dc=ru" "samAccountName=%u" LDAPAuthBinds on
# пользователям назначаем права chown на создание директорий (файлов) LDAPDefaultGID 65534 # group nogroup см. /etc/group LDAPDefaultUID 116 # user proftpd см. /etc/passwd
#uid - user id цифровое значение пользователя (первый не-рут пользователь в сиcтеме как правило 1000, рут - 0 ) #gid - group id цифровое значение группы пользователей (группа users например - 100, группа root 0)
</IfModule>
RequireValidShell off # (авторизовывать клиента только
если он имеет основной shell из списка /et/shells;
область действия - основной сервер, Global, VirtualHost, Anonymous т.е. отключает проверку командного интерпретатора пользователя - это лишнее) UseFtpUsers off PersistentPasswd off
<IfModule mod_auth_pam.c> AuthPAM off # не используем дополнительные PAM модули </IfModule>
-------------------------------------------------------------------------------------------------------------------------------------
Отредактируем файл конфигурации самого ftp сервера /etc/proftp.d/proftpd.conf
------------------------------------------------------------------------------------------------------------------------------------- # /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file. # To really apply changes reload proftpd after modifications.
# Includes DSO modules Include /etc/proftpd/modules.conf
# Set off to disable IPv6 support which is annoying on IPv4 only boxes. UseIPv6 off # If set on you can experience a longer connection delay in many cases. IdentLookups off ServerIdent on "FTP Server ready."
# Приветствие при успешной регистрации на ftp-сервере AccessGrantMsg "WELCOME FTP Server InHibitz"
DebugLevel 10 # включаем более подробный лог
ServerName "Administrator FTP" ServerType standalone DeferWelcome off
MultilineRFC2228 on DefaultServer on ShowSymlinks on
TimeoutNoTransfer 600 TimeoutStalled 600 TimeoutIdle 1200
DisplayLogin welcome.msg DisplayChdir .message true ListOptions "-l"
DenyFilter \*.*/
# Use this to jail all users in their homes DefaultRoot ~
# Users require a valid shell listed in /etc/shells to login. # Use this directive to release that constrain. # RequireValidShell off
# Port 21 is the standard FTP port. Port 21
# In some cases you have to specify passive ports range to by-pass # firewall limitations. Ephemeral ports can be used for that, but # feel free to use a more narrow range. # PassivePorts 49152 65534 # If your host was NATted, this option is useful in order to # allow passive tranfers to work. You have to use your public # address and opening the passive ports used on your firewall as well. # MasqueradeAddress 1.2.3.4
# This is useful for masquerading address with dynamic IPs: # refresh any configured MasqueradeAddress directives every 8 hours <IfModule mod_dynmasq.c> # DynMasqRefresh 28800 </IfModule>
# To prevent DoS attacks, set the maximum number of child processes # to 30. If you need to allow more than 30 concurrent connections # at once, simply increase this value. Note that this ONLY works # in standalone mode, in inetd mode you should use an inetd server # that allows you to limit maximum number of processes per service # (such as xinetd) MaxInstances 30
# Set the user and group that the server normally runs at. User proftpd Group nogroup
# Umask 022 is a good standard umask to prevent new files and dirs # (second parm) from being group and world writable. Umask 022 022 # Normally, we want files to be overwriteable. AllowOverwrite on
# Uncomment this if you are using NIS or LDAP via NSS to retrieve passwords: #PersistentPasswd off
# This is required to use both PAM-based authentication and local passwords #AuthOrder mod_auth_pam.c* mod_auth_unix.c
AuthPAMConfig proftpd
# Be warned: use of this directive impacts CPU average load! # Uncomment this if you like to see progress and transfer rate with ftpwho # in downloads. That is not needed for uploads rates. # # UseSendFile off
TransferLog /var/log/proftpd/xferlog SystemLog /var/log/proftpd/proftpd.log
<IfModule mod_quotatab.c> QuotaEngine off </IfModule>
<IfModule mod_ratio.c> Ratios off </IfModule>
# Delay engine reduces impact of the so-called Timing Attack described in # http://security.lss.hr/index.php?page=details&ID=LSS-2004-10-02 # It is on by default. <IfModule mod_delay.c> DelayEngine on </IfModule>
<IfModule mod_ctrls.c> ControlsEngine off ControlsMaxClients 2 ControlsLog /var/log/proftpd/controls.log ControlsInterval 5 ControlsSocket /var/run/proftpd/proftpd.sock </IfModule>
<IfModule mod_ctrls_admin.c> AdminControlsEngine off </IfModule>
# # Alternative authentication frameworks # Include /etc/proftpd/ldap.conf #Include /etc/proftpd/sql.conf
# # This is used for FTPS connections #
#Include /etc/proftpd/tls.conf
# A basic anonymous configuration, no upload directories.
MaxLoginAttempts 5 "Количество попыток авторизации исчерпано"
-------------------------------------------------------------------------------------------------------------------------------------
и так с конфигурацией закончили. Перейдем к тестированию :)
перезапустим сервис ProFTpd:
root@linuxlo:/etc/proftpd# /etc/init.d/proftpd restart * Stopping ftp server proftpd [ OK ] * Starting ftp server proftpd [ OK ] root@linuxlo:/etc/proftpd#
На ProFTPd сервере есть ftp папка, которая находится в /home/ftp/pub. В ней будут автоматически создаваться домашние папки пользователей из Active Directory с chroot окружением. В качестве ftp клиента можно использовать ncftp. Любой LDAP пользователь при аутентификации на ftp сервере получит свою папку доступа совпадающая с его аккаунтом.
Подключаемся пользователем из LDAP (AD)
root@linuxlo> ncftp -u user1 -p test 192.168.85.134
NcFTP 3.2.2 (Sep 04, 2008) by Mike Gleason (http://www.NcFTP.com/contact/). Connecting to 192.168.85.134... FTP Server ready. Logging in... WELCOME Logged in to 192.168.85.134. ncftp / >
т.е. подключение вполне удалось. Если рассмотреть log действий то увидим, что каталог создался и права выданы
mod_ldap/2.8.20-20090124: generated filter ou=people,dc=domainko,dc=ru from template ou=people,dc=domainko,dc=ru and value user1 mod_ldap/2.8.20-20090124: generated filter samAccountName=user1 from template samAccountName=%u and value user1 mod_ldap/2.8.20-20090124: searched using filter samAccountName=user1 mod_ldap/2.8.20-20090124: fetching value(s) for attr SAMAccountname mod_ldap/2.8.20-20090124: fetching value(s) for attr uidNumber mod_ldap/2.8.20-20090124: no values for attribute uidNumber, trying defaults... mod_ldap/2.8.20-20090124: using default UID 116 mod_ldap/2.8.20-20090124: fetching value(s) for attr gidNumber mod_ldap/2.8.20-20090124: no values for attribute gidNumber, trying defaults... mod_ldap/2.8.20-20090124: using default GID 65534 mod_ldap/2.8.20-20090124: fetching value(s) for attr homeDirectory mod_ldap/2.8.20-20090124: no values for attribute homeDirectory, trying defaults... mod_ldap/2.8.20-20090124: using default homedir /home/ftp/pub/user1 mod_ldap/2.8.20-20090124: fetching value(s) for attr loginShell mod_ldap/2.8.20-20090124: no values for attribute loginShell, trying defaults... mod_ldap/2.8.20-20090124: user user1, uid 116, gid 65534, homedir /home/ftp/pub/user1, shell retrieved UID 116 for user 'user1' RELINQUISH PRIVS at mod_auth.c:571 set TZ environment variable to 'MSK' Preparing to chroot to directory '/home/ftp/pub/user1' ROOT PRIVS at auth.c:1317 RELINQUISH PRIVS at auth.c:1319 Environment successfully chroot()ed ROOT PRIVS at mod_auth.c:1196 SETUP PRIVS at mod_auth.c:1208 in dir_check_full(): path = '/', fullpath = '/home/ftp/pub/user1/'.
Теперь пройдем аутентификацию системного пользователя vlad из Linux (/etc/passwd)
root@linuxlo:/etc/proftpd# ncftp -u vlad -p nec454dfs 192.168.85.134 NcFTP 3.2.2 (Sep 04, 2008) by Mike Gleason (http://www.NcFTP.com/contact/). Connecting to 192.168.85.134... FTP Server ready. Logging in... WELCOME Logged in to 192.168.85.134. ncftp / > ls ./ .dmrc .gnome2/ .nautilus/ .themes/ Загрузки/ .bash_history .esd_auth .gnome2_private/ .profile .thumbnails/ Картинки/ .bash_logout examples.desktop .gtk-bookmarks .pulse/ .update-notifier/ Музыка/ .bashrc .fontconfig/ .ICEauthority .pulse-cookie .xsession-errors Общедоступные/ .cache/ .gconf/ .icons/ .recently-used.xbel .xsession-errors.old Рабочий стол/ .config/ .gconfd/ .local/ .rnd Видео/ Шаблоны/ .dbus/ .gksu.lock .mc/ .sudo_as_admin_successful Документы/ ncftp / >
подключились к домашней директории системных пользователей в /home/vlad
Ну типа на этом всё :)
|