zoukankan      html  css  js  c++  java
  • linux 下安装ftp服务器

    最后重启    # service vsftpd restart
     
    1.查看是否安装vsftp
    rpm -qa | grep ftp
    如果出现    vsftpd-2.0.5-16.el5_5.1  说明已经安装 vsftp
    安装vsftp
    yum -y install vsftpd
    2.测试 是否安装成功  (ip 改成自己啊,不要用俺的此次登录为匿名登录 user: anonymous 密码为空 如果成功登录会有下面内容  这说明vsftpd安装成功)
    [root@localhost~]#service vsftpd start
    为 vsftpd 启动 vsftpd:[确定]
    3.尝试 ftp localhost
    4. 如果报 ftp command not found 说明现在你只是装了 ftpserver,还没有安装ftp客户端。所以安装  yum install –y ftp,安装完毕后搞定。
    最后重启    # service vsftpd restart
    ----------------------------------------------------------------------------------
    设置ftp服务器的账号密码
    A. 登录Linux主机后,运行命令:”useradd ftpadmin -s /sbin/nologin “。该账户路径默认指向/home/ftpadmin目录;如果需要将用户指向其他目录,请运行命令:useradd ftpadmin -s /sbin/nologin –d /www(其他目录)

    B. 设置ftpadmin用户密码,运行命令:”passwd ftpadmin” ; 输入两次密码,匹配成功后,就设置好了ftpadmin用户的密码了。

    C.测试连接,您可以在“我的电脑”地址栏中输入 ftp://IP 来连接FTP服务器,根据提示输入账户密码。
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    2、设置FTP权限


    A. 编辑VSFTP配置文件,运行命令:”vi /etc/vsftpd/vsftpd.conf “

    B. 将配置文件中”anonymous_enable=YES “改为 “anonymous_enable=NO”

    C. 保存修改,按ESC键,运行命令:“:wq”
     

    这样关闭了匿名登录功能。

    --------------------------------------------------------------------------------------------------------------------------------------------
    匿名访问的路径
    如果允许匿名访问 路径是
    /var/ftp/pub
    chomd  777  文件名
    需要给权限。否则传不上去。
     
    ----------------------------------------
    conf下设置
     
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    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
    #
    # The name of log file when xferlog_enable=YES and xferlog_std_format=YES
    # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
    #xferlog_file=/var/log/xferlog
    #
    # Switches between logging into vsftpd_log_file and xferlog_file files.
    # NO writes to vsftpd_log_file, YES to xferlog_file
    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
    # 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=077
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    "vsftpd.conf" 122L, 4677C written                                                                                                                                            
    [root@iZ25bl2cy4qZ vsftpd]# service vsftpd restart
    Shutting down vsftpd:                                      [  OK  ]
    Starting vsftpd for vsftpd:                                [  OK  ]
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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=000
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    "vsftpd.conf" 122L, 4677C written                                                                                                                                            
    [root@iZ25bl2cy4qZ vsftpd]# service vsftpd restart
    Shutting down vsftpd:                                      [  OK  ]
    Starting vsftpd for vsftpd:                                [  OK  ]
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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=000
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    "vsftpd.conf" 122L, 4677C written
    [root@iZ25bl2cy4qZ vsftpd]# cd /proc/
    [root@iZ25bl2cy4qZ proc]# cd /var/ftp/
    [root@iZ25bl2cy4qZ ftp]# cd pub/
    [root@iZ25bl2cy4qZ pub]# ls
    123123.jpg  13.jpg  3213.jpg  34131.jpg  zhangfuxin.jpg
    [root@iZ25bl2cy4qZ pub]# chmod 777 123123.jpg 
    [root@iZ25bl2cy4qZ pub]# ls -l
    total 2580
    -rwxrwxrwx 1 root ftp      525705 Nov 29 22:55 123123.jpg
    -rwxrwxrwx 1 root ftp      525705 Nov 29 22:42 13.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:03 3213.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:01 34131.jpg
    -rw-r--r-- 1  777 ftpadmin 525705 Nov 28 23:19 zhangfuxin.jpg
    [root@iZ25bl2cy4qZ pub]# cd /etc/vsftpd/
    [root@iZ25bl2cy4qZ vsftpd]# ls
    ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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=0000
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    "vsftpd.conf" 122L, 4678C written                                                                                                                                            
    [root@iZ25bl2cy4qZ vsftpd]# service vsftpd restart
    Shutting down vsftpd:                                      [  OK  ]
    Starting vsftpd for vsftpd:                                [  OK  ]
    [root@iZ25bl2cy4qZ vsftpd]# cd /etc/vsftpd/
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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=0000
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    "vsftpd.conf" 122L, 4679C written                                                                                                                                            
    [root@iZ25bl2cy4qZ vsftpd]# service vsftpd restart
    Shutting down vsftpd:                                      [  OK  ]
    Starting vsftpd for vsftpd:                                [  OK  ]
    [root@iZ25bl2cy4qZ vsftpd]# vim vsftpd.conf 
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    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
    #
    # The name of log file when xferlog_enable=YES and xferlog_std_format=YES
    # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
    "vsftpd.conf" 122L, 4678C written                                                                                                                                            
    [root@iZ25bl2cy4qZ vsftpd]# service vsftpd restart
    Shutting down vsftpd:                                      [  OK  ]
    Starting vsftpd for vsftpd:                                [  OK  ]
    [root@iZ25bl2cy4qZ vsftpd]# ^C
    [root@iZ25bl2cy4qZ vsftpd]# ^C
    [root@iZ25bl2cy4qZ vsftpd]# pwd
    /etc/vsftpd
    [root@iZ25bl2cy4qZ vsftpd]# cd /var/
    [root@iZ25bl2cy4qZ var]# ls
    account  cache  crash  cvs  db  empty  ftp  games  lib  local  lock  log  mail  nis  opt  preserve  run  spool  tmp  yp
    [root@iZ25bl2cy4qZ var]# cd ftp/
    [root@iZ25bl2cy4qZ ftp]# ls
    pub
    [root@iZ25bl2cy4qZ ftp]# cd pub/
    [root@iZ25bl2cy4qZ pub]# ls
    123123.jpg  13.jpg  243234.jpg  3213.jpg  34131.jpg  5555.jpg  888.jpg  999.jpg  zhangfuxin.jpg
    [root@iZ25bl2cy4qZ pub]# ls- l
    -bash: ls-: command not found
    [root@iZ25bl2cy4qZ pub]# ls- s
    -bash: ls-: command not found
    [root@iZ25bl2cy4qZ pub]# ls-l
    -bash: ls-l: command not found
    [root@iZ25bl2cy4qZ pub]# lpwd
    -bash: lpwd: command not found
    [root@iZ25bl2cy4qZ pub]# pwd
    /var/ftp/pub
    [root@iZ25bl2cy4qZ pub]# ls
    123123.jpg  13.jpg  243234.jpg  3213.jpg  34131.jpg  5555.jpg  888.jpg  999.jpg  zhangfuxin.jpg
    [root@iZ25bl2cy4qZ pub]# ls -l
    total 4644
    -rwxrwxrwx 1 root ftp      525705 Nov 29 22:55 123123.jpg
    -rwxrwxrwx 1 root ftp      525705 Nov 29 22:42 13.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:09 243234.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:03 3213.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:01 34131.jpg
    -rw------- 1 root ftp      525705 Nov 29 23:13 5555.jpg
    -rw------- 1 ftp  ftp      525705 Nov 29 23:17 888.jpg
    -rw------- 1 ftp  ftp      525705 Nov 29 23:17 999.jpg
    -rw-r--r-- 1  777 ftpadmin 525705 Nov 28 23:19 zhangfuxin.jpg
    [root@iZ25bl2cy4qZ pub]# clear
    [root@iZ25bl2cy4qZ pub]# vim /etc/vsftpd/vsftpd.conf 
    #
    # 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
    #non_mkdir_write_enable=YES
    #new directories.
    anon_mkdir_write_enable=YES
    anon_world_readable_only=no
    anon_other_write_enable=YES
    #
    # Activate directory messages - messages given to remote users when they
    # go into a certain directory.
    dirmessage_enable=YES
    #
    # The target log file can be vsftpd_log_file or xferlog_file.
    # This depends on setting xferlog_std_format parameter
    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
    "/etc/vsftpd/vsftpd.conf" 122L, 4678C                                                                                                                                        50,1          11%
  • 相关阅读:
    几个新角色:数据科学家、数据分析师、数据(算法)工程师
    人类投资经理再也无法击败电脑的时代终将到来了...
    Action Results in Web API 2
    Multiple actions were found that match the request in Web Api
    Routing in ASP.NET Web API
    how to create an asp.net web api project in visual studio 2017
    网站漏洞扫描工具
    How does asp.net web api work?
    asp.net web api history and how does it work?
    What is the difference between a web API and a web service?
  • 原文地址:https://www.cnblogs.com/zfxJava/p/5594112.html
Copyright © 2011-2022 走看看