zoukankan      html  css  js  c++  java
  • Linux Vsftpd 连接超时解决方法(被动模式)

    http://blog.csdn.net/qq_15766181/article/details/46554643

    使用 FileZilla FTP Client 连接 Vsftpd FTP,在没有配置传输模式(主动模式、被动模式)时,出现了以下提示信息。我们可以手工设置传输模式为“主动模式”来解决这一问题。但由于客户端防火墙等原因,这种解决方法将不会始终有效。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    状态: 正在连接 192.168.182.128:21...
    状态: 连接建立,等待欢迎消息...
    响应: 220 (vsFTPd 2.0.5)
    命令: USER bugxm_general
    响应: 331 Please specify the password.
    命令: PASS ******
    响应: 230 Login successful.
    命令: OPTS UTF8 ON
    响应: 200 Always in UTF8 mode.
    状态: 已连接
    状态: 读取目录列表...
    命令: PWD
    响应: 257 "/"
    命令: TYPE I
    响应: 200 Switching to Binary mode.
    命令: PASV
    响应: 227 Entering Passive Mode (192,168,182,128,172,85)
    命令: LIST
    错误: 连接超时
    错误: 读取目录列表失败

    解决方法

    在服务端配置被动模式就可以从根源上解决这问题。

    1、编辑 Vsftpd  配置文件

    1
    vi /etc/vsftpd/vsftpd.conf

    2、在最下面添加以下信息

    1
    2
    3
    pasv_enable=YES         #开启被动模式
    pasv_min_port=4000      #随机最小端口
    pasv_max_port=5000      #随机最大端口

    3、加载内核 ip_conntrack_ftp 和 ip_nat_ftp(终端执行)

    1
    2
    modprobe ip_conntrack_ftp
    modprobe ip_nat_ftp

    4、配置 iptables 开放 4000 到 5000 端口

    1
    vi /etc/sysconfig/iptables  在*filter下加入下
    1
    2
    -A OUTPUT -p tcp --sport 4000:5000 -j ACCEPT
    -A INPUT -p tcp --dport 4000:5000 -j ACCEPT

    5、加载 iptables 配置

    1
    iptables-restore < /etc/sysconfig/iptables

    6、重启 Vsftpd

    1
    service vsftpd restart

    测试连接

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    状态: 正在连接 192.168.182.128:21...
    状态: 连接建立,等待欢迎消息...
    响应: 220 (vsFTPd 2.0.5)
    命令: USER bugxm_general
    响应: 331 Please specify the password.
    命令: PASS ******
    响应: 230 Login successful.
    命令: OPTS UTF8 ON
    响应: 200 Always in UTF8 mode.
    状态: 已连接
    状态: 读取目录列表...
    命令: PWD
    响应: 257 "/"
    命令: TYPE I
    响应: 200 Switching to Binary mode.
    命令: PASV
    响应: 227 Entering Passive Mode (192,168,182,128,15,224)
    命令: LIST
    响应: 150 Here comes the directory listing.
    响应: 226 Directory send OK.
    状态: 列出目录成功
    #%PAM-1.0 [/etc/pam.d/vsftpd, 注意是lib还是lib64, 登录失败 可 tail -f /var/log/secure 查看详情]
    auth    sufficient      /lib64/security/pam_userdb.so     db=/etc/vsftpd/virtusers
    account sufficient      /lib64/security/pam_userdb.so     db=/etc/vsftpd/virtusers
    session    optional     pam_keyinit.so    force revoke
    auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
    auth       required     pam_shells.so
    auth       include      password-auth
    account    include      password-auth
    session    required     pam_loginuid.so
    session    include      password-auth
  • 相关阅读:
    Nodejs Express4.x学习笔记
    OSG学习 错误与心得
    Qt Visual Studio Add-in安装
    OSG安装配置
    钩子
    不要去追一匹马,用追马的时间种草
    intellij Idea 报jdk错误
    flex 安全沙箱问题
    webuploader
    文件上传下载
  • 原文地址:https://www.cnblogs.com/lixiuran/p/6179617.html
Copyright © 2011-2022 走看看