Rac*_*cer 3 ftp arch-linux vsftpd
我目前正在努力解决 vsftpd 的某种连接问题。
我正在使用 arch linux 并安装了 vsftpd 3.0.3 版。
我不使用 iptables 或任何东西。当我连接到我的 FTP 服务器时,我能够成功登录和浏览目录。我还可以上传和下载文件。
FTP 用户被 chroot 到他的主目录,所有子目录都归 ftp 用户所有。
目前的结构:
|- home_dir
|- dir1
|- dir2
|- dir3
|- dir3
|- dir4
|- ...
Run Code Online (Sandbox Code Playgroud)
我可以“cd”到 dir1,执行“ls”并上传/下载文件。我也可以“cd”到 dir2,但这里是棘手的部分:
我可以完美地将文件上传到 dir2,但是当我执行“ls”时,服务器正在关闭连接说:“421 服务不可用,远程服务器已关闭连接”。我发现,原因是“dir2”的几个子目录。我发现,所有子目录中的 8 个都导致连接被关闭。一旦我删除它们,列表就可以正常工作。所有名称都包含从 a 到 z 的小写字母,没有特殊字符。
我的ftp配置:
log_ftp_protocol=YES
anonymous_enable=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO
pasv_addr_resolve=YES
pasv_address=mydomain.com
pasv_enable=Yes
pasv_min_port=40020
pasv_max_port=40030
local_enable=YES
write_enable=YES
local_umask=002
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=myuser
ftpd_banner=Welcome.
chroot_local_user=YES
Run Code Online (Sandbox Code Playgroud)
这就是服务器 FTP-Log 所说的:
Wed Dec 28 13:55:06 2016 [pid 2] CONNECT: Client "<client_ip>"
Wed Dec 28 13:55:06 2016 [pid 2] FTP response: Client "<client_ip>", "220 Welcome."
Wed Dec 28 13:55:07 2016 [pid 2] FTP command: Client "<client_ip>", "USER myuser"
Wed Dec 28 13:55:07 2016 [pid 2] [myuser] FTP response: Client "<client_ip>", "331 Please specify the password."
Wed Dec 28 13:55:07 2016 [pid 2] [myuser] FTP command: Client "<client_ip>", "PASS <password>"
Wed Dec 28 13:55:07 2016 [pid 1] [myuser] OK LOGIN: Client "<client_ip>"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "230 Login successful."
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "OPTS UTF8 ON"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "200 Always in UTF8 mode."
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "PWD"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "257 "/" is the current directory"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "TYPE I"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "200 Switching to Binary mode."
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "PASV"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "227 Entering Passive Mode (<server_ip>,156,86)."
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "LIST"
Wed Dec 28 13:55:07 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "150 Here comes the directory listing."
Wed Dec 28 13:55:08 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "226 Directory send OK."
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "CWD /dir1"
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "250 Directory successfully changed."
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "PASV"
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "227 Entering Passive Mode (<server_ip>,156,92)."
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "LIST"
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "150 Here comes the directory listing."
Wed Dec 28 13:55:09 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "226 Directory send OK."
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "CWD /dir1/dir2"
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "250 Directory successfully changed."
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "PASV"
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "227 Entering Passive Mode (<server_ip>,156,87)."
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP command: Client "<client_ip>", "LIST"
Wed Dec 28 13:55:11 2016 [pid 3] [myuser] FTP response: Client "<client_ip>", "150 Here comes the directory listing."
Run Code Online (Sandbox Code Playgroud)
日志总是在“150 Here come the directory listing.”之后停止。我试了几次。
这就是我看到的,当我在终端上使用 ftp 命令时:
$ ftp -n 127.0.0.1
Connected to 127.0.0.1.
220 Welcome.
ftp> user myuser
331 Please specify the password.
Password:
230 Login successful.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x 4 1000 1000 4096 Dec 28 13:27 dir1
226 Directory send OK.
ftp> cd dir1
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rwxr-xr-x 1 1000 1000 469504 Dec 23 03:03 file_1
-rw-r--r-- 1 1000 1000 186 Feb 19 2016 file_2
-rw-r--r-- 1 1000 1000 121856 Dec 23 00:16 file_3
-rw-r--r-- 1 1000 1000 118272 Feb 12 2016 file_4
-rw-r--r-- 1 1000 1000 88232 Mar 22 2016 file_5
-rw-r--r-- 1 1000 1000 64680 Mar 22 2016 file_6
-rw-r--r-- 1 1000 1000 101032 Mar 22 2016 file_7
-rw-r--r-- 1 1000 1000 6144 Mar 22 2016 file_8
-rw-r--r-- 1 1000 1000 899584 Mar 22 2016 file_9
drwxrwxr-x 42 1000 1000 4096 Dec 28 11:38 dir2
226 Directory send OK.
ftp> cd dir2
250 Directory successfully changed.
ftp> pwd
257 "/dir1/dir2" is the current directory
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
421 Service not available, remote server has closed connection
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助。
小智 5
我通过添加以下内容解决了目录列表失败且文件数超过 10 个(如Chistian Mund 所述)的问题
seccomp_sandbox=NO
到 /etc/vsftpd.conf
来源Arch 维基