Proftpd. Centos 7
Установка
yum install proftpd
Настройка
nano /etc/hosts
... <ip_машины> <доменное имя машины> # например: 192.168.17.7 centos6 ...
useradd userftp -d /home/ftp_dir -s /bin/false
passwd userftp
chown userftp:userftp /home/ftp_dir
chmod -R 775 /home/ftp_dir
nano /etc/proftpd.conf
# To really apply changes reload proftpd after modifications. AllowOverwrite on AuthAliasOnly off # Choose here the user alias you want !!!! #UserAlias sauron userftp ServerName "asterisk" ServerType standalone DeferWelcome on MultilineRFC2228 on DefaultServer on ShowSymlinks off TimeoutNoTransfer 600 TimeoutStalled 100 TimeoutIdle 2200 DisplayChdir .message ListOptions "-l" RequireValidShell off TimeoutLogin 20 RootLogin off # It's better for debug to create log files ;-) ExtendedLog /var/log/ftp.log TransferLog /var/log/xferlog SystemLog /var/log/syslog.log #DenyFilter \*.*/ # I don't choose to use /etc/ftpusers file (set inside the users you want to ban, not useful for me) UseFtpUsers off # Allow to restart a download AllowStoreRestart on # Port 21 is the standard FTP port, so you may prefer to use another port for security reasons (choose here the port you want) Port 21 # 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 8 # Set the user and group that the server normally runs at. User nobody Group nobody # Umask 022 is a good standard umask to prevent new files and dirs # (second parm) from being group and world writable. Umask 022 022 PersistentPasswd off MaxClients 8 MaxClientsPerHost 8 MaxClientsPerUser 8 MaxHostsPerUser 8 # Display a message after a successful login AccessGrantMsg "welcome !!!" # This message is displayed for each access good or not ServerIdent on "you're at home" # Lock all the users in home directory, ***** really important ***** DefaultRoot ~ MaxLoginAttempts 5 #VALID LOGINS <Limit LOGIN> AllowUser userftp AllowUser callrec DenyALL </Limit>
service proftpd start
chkconfig proftpd on
Проверить синтаксис proftpd.conf
proftpd -td5
Тестирование
Запускаем на одной консоли
proftpd -n -d 5
На второй
ftp localhost
Смотрим дебаг на первой консоли
Авторизация под пользователем из MYSQL
Установка
yum install proftpd-mysql
Настройка БД
mysql -u root -p
CREATE DATABASE proftpd CHARACTER SET UTF8;
GRANT ALL PRIVILEGES ON proftpd.* TO proftpd_user@localhost IDENTIFIED BY 'x8915rk';
CREATE TABLE `proftpd`.`users` (`username` VARCHAR( 32 ) NOT NULL ,`password` VARCHAR( 32 ) NOT NULL ,`uid` INT NOT NULL ,`gid` INT NOT NULL ,`homedir` VARCHAR( 255 ) NOT NULL ,`shell` VARCHAR( 255 ) NOT NULL ,UNIQUE (`username`)) CHARACTER SET utf8 COLLATE utf8_general_ci;
INSERT INTO `proftpd`.`users` (`username`, `password`, `uid`, `gid`, `homedir`, `shell`) VALUES ('user03', 'user03', '33', '33', '/var/www/html/ftp', '/bin/false' );
Настройка Proftpd
nano /etc/proftpd.conf
... <Limit LOGIN> AllowUser user03 AllowUser user04 DenyALL </Limit> LoadModule mod_sql.c LoadModule mod_sql_mysql.c Include /etc/proftpd/sql.conf AuthOrder mod_sql.c mod_auth_unix.c ...
nano /etc/proftpd/sql.conf
<IfModule mod_sql.c> # Cообщаем, что намерены работать с СУБД MySQL SQLBackend mysql SQLEngine on # Пароли в базе храняться в открытом формате SQLAuthTypes Plaintext # Подключаемся к БД proftpd пользователем proftpd_user с паролем proftpd_password SQLConnectInfo proftpd@localhost proftpd_user proftpd_password # Выбираем данные из таблицы users SQLUserInfo users username password uid gid homedir shell # Аутентифицируем пользователей из этой таблицы SQLAuthenticate users* # По умолчанию минимальный UserID пользователя и GroupID =999 SQLMinUserUID 33 SQLMinUserGID 33 # На время отладки пишем логи SQLLogFile /var/log/proftpd/sql.log
Перезапуск службы
service proftpd restart