Для начала с белым списком разберёмся.
Белые и чёрные списки работают так:
Shell
man vsftpd.conf
...
userlist_deny
This option is examined if userlist_enable is activated. If you set this setting to NO, then users will be denied login unless they are
explicitly listed in the file specified by userlist_file. When login is denied, the denial is issued before the user is asked for a
password.
Default: YES
userlist_enable
If enabled, vsftpd will load a list of usernames, from the filename given by userlist_file. If a user tries to log in using a name in
this file, they will be denied before they are asked for a password. This may be useful in preventing cleartext passwords being trans‐
mitted. See also userlist_deny.
Default: NOВ этом всём меня смущают две вещи. В случает работы белого списка написано:userlist_deny=YES
userlist_enable=NO
никакие списки не работают, соединения всех юзеров по ftp разрешены, умолчальный вариант
userlist_deny=YES
userlist_enable=YES
работает чёрный список
userlist_deny=NO
работает белый список
А что ж за файл-то такой userlist_file?If you set this setting to NO, then users will be denied login unless they are explicitly listed in the file specified by userlist_file.
Shell
man vsftpd.conf
...
userlist_file
This option is the name of the file loaded when the userlist_enable option is active.
Default: /etc/vsftpd.user_list...Да, и /etc/vsftpd.user_list отсутствует. Ну ладно, создадим.
В общем, считаем пока, что userlist_file для белого списка вполне себе годится. Настраиваем белый список. На сервере (поднят vsftpd):
Два пользователя, qqq и www
Shell
$ cat /etc/passwd | tail -2
qqq:x:1001:1001:,,,:/home/qqq:/bin/bash
www:x:1002:1002:,,,:/home/www:/bin/bash
$Shell
$ sudo cat /home/www/www_file.txt
www_text
$Shell
$ grep userlist_deny /etc/vsftpd.conf
userlist_deny=NO
$Shell
$ cat /etc/vsftpd.user_list
qqq
$Shell
$ ip a | grep "inet" | grep -v "inet 127\|inet6" | awk '{print $2}'
10.54.28.252/23
$Ну и всё, собсно. Из соседнего компьютера в консоли с ftp-сервером пользователем www соединяемся и файл www_file.txt качаем:
Shell
$ ftp ftp://www:www@10.54.28.252
Connected to 10.54.28.252.
220 (vsFTPd 3.0.3)
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Switching to Binary mode.
ftp>
ftp> get www_file.txt
local: www_file.txt remote: www_file.txt
229 Entering Extended Passive Mode (|||27116|)
150 Opening BINARY mode data connection for www_file.txt (9 bytes).
100% |************************************************| 9 89.68 KiB/s 00:00 ETA
226 Transfer complete.
9 bytes received in 00:00 (20.92 KiB/s)
ftp>
ftp> exit
221 Goodbye.
$Shell
$ cat www_file.txt
www_text
$