红联Linux门户
Linux帮助

ftp服务器无法连接

发布时间:2009-07-10 13:24:30来源:红联作者:whymkevin
系统版本 ubuntu 9.04 server
VSFTPD.CONF
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
chroot_local_user=YES
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
#
# Debian customization
#
# Some of vsftpd's settings don't fit the Debian filesystem layout by
# default. These settings are more Debian-friendly.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
#允许虚拟用户
guest_enable=YES
#把虚拟用户映射成本地用户
guest_username=ftp
#虚拟用户的权限设置目录
user_config_dir=/etc/vsftpd/vsftpd_user_conf
无法连接 显示无法找到主机
在终端中输入 FTP 地址,出现ftp: connect: Connection refused
不知道什么原因
文章评论

共有 26 条评论

  1. whymkevin 于 2009-07-12 11:57:50发表:

    IP没错 可能是配置上的问题 现在好了

  2. hyqhyq_3 于 2009-07-12 09:52:41发表:

    没搞错IP吧,怎么可能找不到主机呢

  3. whymkevin 于 2009-07-10 14:48:16发表:

    可以了 非常感学 ! 高手 还请以后多指教 呵呵 (e:e2s

  4. bbsytc 于 2009-07-10 14:44:26发表:

    [i=s] 本帖最后由 bbsytc 于 2009-7-10 14:45 编辑 [/i]

    # Example config file /etc/vsftpd/vsftpd.conf
    #
    # The default compiled in settings are fairly paranoid. This sample file
    # loosens things up a bit, to make the ftp daemon more usable.
    # Please see vsftpd.conf.5 for all compiled in defaults.
    #
    # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
    # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
    # capabilities.
    #
    # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
    anonymous_enable=YES
    #
    # Uncomment this to allow local users to log in.
    local_enable=YES
    #
    # Uncomment this to enable any form of FTP write command.
    write_enable=YES
    #
    # Default umask for local users is 077. You may wish to change this to 022,
    # if your users expect that (022 is used by most other ftpd's)
    local_umask=022
    #
    # Uncomment this to allow the anonymous FTP user to upload files. This only
    # has an effect if the above global write enable is activated. Also, you will
    # obviously need to create a directory writable by the FTP user.
    #anon_upload_enable=YES
    #
    # Uncomment this if you want the anonymous FTP user to be able to create
    # new directories.
    #anon_mkdir_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    # Example config file /etc/vsftpd/vsftpd.conf
    #
    # The default compiled in settings are fairly paranoid. This sample file
    # loosens things up a bit, to make the ftp daemon more usable.
    # Please see vsftpd.conf.5 for all compiled in defaults.
    #
    # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
    # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
    # capabilities.
    #
    # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
    anonymous_enable=NO
    #
    # Uncomment this to allow local users to log in.
    local_enable=YES
    #
    # Uncomment this to enable any form of FTP write command.
    write_enable=YES
    #
    # Default umask for local users is 077. You may wish to change this to 022,
    # if your users expect that (022 is used by most other ftpd's)
    local_umask=022
    #
    # Uncomment this to allow the anonymous FTP user to upload files. This only
    # has an effect if the above global write enable is activated. Also, you will
    # obviously need to create a directory writable by the FTP user.
    #anon_upload_enable=YES
    #
    # Uncomment this if you want the anonymous FTP user to be able to create
    # new directories.
    #anon_mkdir_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # Activate logging of uploads/downloads.
    xferlog_enable=YES
    #
    # Make sure PORT transfer connections originate from port 20 (ftp-data).
    connect_from_port_20=YES
    #
    # If you want, you can arrange for uploaded anonymous files to be owned by
    # a different user. Note! Using "root" for uploaded files is not
    # recommended!
    #chown_uploads=YES
    #chown_username=whoever
    #
    # You may override where the log file goes if you like. The default is shown
    # below.
    #xferlog_file=/var/log/vsftpd.log
    #
    # If you want, you can have your log file in standard ftpd xferlog format
    xferlog_std_format=YES
    #
    # You may change the default value for timing out an idle session.
    #idle_session_timeout=600
    #
    # You may change the default value for timing out a data connection.
    #data_connection_timeout=120
    #
    # It is recommended that you define on your system a unique user which the
    # ftp server can use as a totally isolated and unprivileged user.
    #nopriv_user=ftpsecure
    #
    # Enable this and the server will recognise asynchronous ABOR requests. Not
    # recommended for security (the code is non-trivial). Not enabling it,
    # however, may confuse older FTP clients.
    #async_abor_enable=YES
    #
    # By default the server will pretend to allow ASCII mode but in fact ignore
    # the request. Turn on the below options to have the server actually do ASCII
    # mangling on files when in ASCII mode.
    # Beware that turning on ascii_download_enable enables malicious remote parties
    # to consume your I/O resources, by issuing the command "SIZE /big/file" in
    # ASCII mode.
    # These ASCII options are split into upload and download because you may wish
    # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
    # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
    # on the client anyway..
    #ascii_upload_enable=YES
    #ascii_download_enable=YES
    #
    # You may fully customise the login banner string:
    ftpd_banner=Chen Tai Fong FTP
    #
    # You may specify a file of disallowed anonymous e-mail addresses. Apparently
    # useful for combatting certain DoS attacks.
    #deny_email_enable=YES
    # (default follows)
    #banned_email_file=/etc/vsftpd.banned_emails
    #
    # You may specify an explicit list of local users to chroot() to their home
    # directory. If chroot_local_user is YES, then this list becomes a list of
    # users to NOT chroot().
    chroot_list_enable=YES
    # (default follows)
    chroot_list_file=/etc/vsftpd.chroot_list
    #
    # You may activate the "-R" option to the builtin ls. This is disabled by
    # default to avoid remote users being able to cause excessive I/O on large
    # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
    # the presence of the "-R" option, so there is a strong case for enabling it.
    #ls_recurse_enable=YES
    pam_service_name=vsftpd
    userlist_enable=YES
    #enable for standalone mode
    listen=YES
    tcp_wrappers=YES

    完成之后,设一下使用者禁止溜出家目录
    vi /etc/vsftpd.chroot_list
    xxx
    xxx
    :wq

    接下来防火墙部份
    /sbin/iptables -A INPUT -p TCP -i eth0 --dport 21 -j ACCEPT
    或是可以直接把防火墙设定值清空也是可以通,只是多了危险就是

    最后restart一下就可以用啦

  5. bbsytc 于 2009-07-10 14:42:20发表:

    [i=s] 本帖最后由 bbsytc 于 2009-7-10 14:45 编辑 [/i]

    chkconfig --list | grep vsftpd
    vsftpd 0:on 1:on 2:on 3:on 4:on 5:on 6:on #确认看到有安装
    chkconfig vsftpd on
    service vsftpd strat

  6. whymkevin 于 2009-07-10 14:35:31发表:

    kevin@kevin:~$ sudo apt-get install vsftpd
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树
    正在读取状态信息... 完成
    vsftpd 已经是最新的版本了。
    共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级

  7. whymkevin 于 2009-07-10 14:35:13发表:

    kevin@kevin:~$ sudo apt-get install vsftpd
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树
    正在读取状态信息... 完成
    vsftpd 已经是最新的版本了。
    共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级

  8. whymkevin 于 2009-07-10 14:35:11发表:

    kevin@kevin:~$ sudo apt-get install vsftpd
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树
    正在读取状态信息... 完成
    vsftpd 已经是最新的版本了。
    共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级

  9. whymkevin 于 2009-07-10 14:35:10发表:

    kevin@kevin:~$ chkconfig --list | grep vsftpd
    vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    kevin@kevin:~$ chkconfig vsftpd on
    kevin@kevin:~$ chkconfig --list | grep vsftpd
    vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    。。。。。这个是什么意思啊

  10. whymkevin 于 2009-07-10 14:34:00发表:

    kevin@kevin:~$ chkconfig --list | grep vsftpd
    vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    kevin@kevin:~$ chkconfig vsftpd on
    kevin@kevin:~$ chkconfig --list | grep vsftpd
    vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    。。。。。这个是什么意思啊

  11. bbsytc 于 2009-07-10 14:32:20发表:

    你重新安装试试sudo apt-get install vsftpd

  12. bbsytc 于 2009-07-10 14:31:39发表:

    11# whymkevin


    sudo /etc/init.d/vsftpd restart

  13. bbsytc 于 2009-07-10 14:28:26发表:

    FTP服务器软件有没有被安装?
    可以通过RPM的命令进行检查。运行如下命令可以确认软件包是否已经被安装.
    rpm -q vsftpd
    如果该软件包已经被安装,该命令会返回格式类似package_name-的输出。如果没有这个软件包,该命令会输出:package package_name is not installed.


    FTP服务有没有在运行,有没有监听客户端的请求?
    如果该软件包已经被安装,就可以把FTP服务打开,这个操作可以通过命令chkconfig实现,然后通过servive命令把FTP服务立即启动.
    # chkconfig --list | grep vsftpd
    vsftpd: off
    # chkconfig vsftpd on
    # chkconfig --list | grep vsftpd
    vsftpd: on
    # service xinetd reload
    Reloading configuration: [ OK ]
    命令chkconfig可以使FTP 服务器在下次系统引导的时候自动启动,注意FTP不是一个单独的服务,他是存在于xinetd(超级服务器),如果需要马上启动服务,可以使用 service xinetd reload命令启动,这个命令会重新读取和使用xinetd的配置文件,可以通过检查FTP的监听端口来查看服务,默认情况下监听端口是21,命令是 netstat -a | grep ftp.。输出如例子所示:

    # netstat -a | grep ftp
    tcp 0 0 *:ftp *:* LISTEN


    这个用户是否有权限FTP到服务器上?
    如果还不能正确的登录到FTP服务器,清检查你的用户是否有权限访问FTP服务器,默认情况下,基于安全的考虑,root用户不能访问FTP到Ubuntu9.04server机器。其他的系统用户都可以访问FTP服务。可以通过检查文件/etc/ftpaccess确认。

    # Don't allow system accounts to log in over ftp
    deny-uid %-99 %65534-
    deny-gid %-99 %65534-
    allow-uid ftp
    allow-gid ftp

    因为所有的用户帐号的UID应该大于等于500, 默认的ftpaccess文件是允许普通系统用户访问FTP的。

    现在就可以成功的通过FTP连接到Ubuntu9.04server上。
    # ftp flanders.example.com
    Connected to flanders.example.com.
    220 flanders.example.com FTP server (Version ) ready.
    530 Please login with USER and PASS.
    530 Please login with USER and PASS.
    KERBEROS_V4 rejected as an authentication type
    Name (flanders:frodo):
    331 Password required for frodo.
    Password:
    230 User frodo logged in.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp>

  14. whymkevin 于 2009-07-10 14:21:39发表:

    kevin@kevin:~$ service vsftpd start
    * Starting FTP server: vsftpd start-stop-daemon: Unable to open pidfile `/var/run/vsftpd/vsftpd.pid' for writing: Permission denied (Permission denied)
    [ OK ]
    kevin@kevin:~$ ftp 127.0.0.1
    ftp: connect: Connection refused
    ftp> ftp 127.0.0.1
    ?Invalid command
    还是这样 郁闷了

  15. bbsytc 于 2009-07-10 14:18:42发表:

    #ftp 127.0.0.1 测试

  16. bbsytc 于 2009-07-10 14:18:22发表:

    #service vsftpd start

  17. whymkevin 于 2009-07-10 14:18:21发表:

    恩 vsftpd已经安装了 几个用户的权限我也分配了 我觉得可能是FTP服务没运行 一直都是显示找不到主机 sudo /etc/init.d/vsftpd start这个命令也用过 还是不行

  18. bbsytc 于 2009-07-10 14:16:36发表:

    8# whymkevin


    #netstat -na --ip

  19. bbsytc 于 2009-07-10 14:14:49发表:

    解决方法:
    首先需要检查如下几个条件:
    FTP服务器软件有没有被安装?
    FTP服务有没有在运行,有没有监听客户端的请求?
    这个用户是否有权限FTP到服务器上?

  20. whymkevin 于 2009-07-10 14:12:36发表:

    ..... 这个不知道在哪里打开阿 我才学LINUX一个多月

  21. bbsytc 于 2009-07-10 14:10:07发表:

    port 21 打开 没有

  22. whymkevin 于 2009-07-10 14:08:08发表:

    恩,我试试看 在UBUNTU9.04上配置成功了 用9.04server就不行 汗啊!):o:s

  23. bbsytc 于 2009-07-10 14:01:47发表:

    use_config_dir=/etc/vsftpd/userconf

  24. whymkevin 于 2009-07-10 13:55:59发表:

    配置好以后重启了 sudo /etc/init.d/vsftpd restart

  25. bbsytc 于 2009-07-10 13:53:31发表:

      nonymous_enable=YES //允许匿名访问,这是匿名服务器必须的

  26. l460618498 于 2009-07-10 13:42:07发表:

    服务启动没??有没有关防火墙