centos 搭建FTP伺服器

來源:互聯網
上載者:User

標籤:ftp   windows   vsftpd   設定檔   centos伺服器   

近期準備把windows 上的ftp停用了,既然一門心思學CENTOS 正好也有這個需求,那就邊學習邊搭建一個FTP服務好了,正好實踐一下。

rpm -qa |grep vsftp      #查看本機是否安裝了ftp服務

如果沒有安裝使用命令進行安裝。

yum install -y vsftpd

安裝完成使用將ftp服務啟動,並將其設定為開機啟動:

然後進行ftp設定檔修改,檔案位於/etc/vsftpd/vsftpd.conf

chkconfig vsftpd onservice vsftpd start
# Example config file /etc/vsftpd/vsftpd.conf  2 #  3 # The default compiled in settings are fairly paranoid. This sample file  4 # loosens things up a bit, to make the ftp daemon more usable.  5 # Please see vsftpd.conf.5 for all compiled in defaults.  6 #  7 # READ THIS: This example file is NOT an exhaustive list of vsftpd options.  8 # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd‘s  9 # capabilities. 10 # 11 # Allow anonymous FTP? (Beware - allowed by default if you comment this out). 12 anonymous_enable=YES 13 # 14 # Uncomment this to allow local users to log in. 15 local_enable=YES 16 # 17 # Uncomment this to enable any form of FTP write command. 18 write_enable=YES 19 # 20 # Default umask for local users is 077. You may wish to change this to 022, 21 # if your users expect that (022 is used by most other ftpd‘s) 22 local_umask=022 23 # 24 # Uncomment this to allow the anonymous FTP user to upload files. This only 25 # has an effect if the above global write enable is activated. Also, you will 26 # obviously need to create a directory writable by the FTP user. 27 # 允許匿名使用者進行上傳操作 28 anon_upload_enable=YES 29 # 30 # Uncomment this if you want the anonymous FTP user to be able to create 31 # new directories. 32 # 可以通過匿名使用者進行檔案夾的建立操作 33 #anon_mkdir_write_enable=YES 34   31 # new directories. 32 # 可以通過匿名使用者進行檔案夾的建立操作 33 #anon_mkdir_write_enable=YES 34  35 #可以通過匿名使用者進行刪除檔案操作 36 #anon_other_write_enable=YES 37 # 38 # Activate directory messages - messages given to remote users when they 39 # go into a certain directory. 40 dirmessage_enable=YES 41 # 42 # The name of log file when xferlog_enable=YES and xferlog_std_format=YES 43 # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log 44 xferlog_file=/var/log/vsftpd.log 45 # 46 # The target log file can be vsftpd_log_file or xferlog_file. 47 # This depends on setting xferlog_std_format parameter 48 xferlog_enable=YES 49 # 50 # Switches between logging into vsftpd_log_file and xferlog_file files. 51 # NO writes to vsftpd_log_file, YES to xferlog_file 52 xferlog_std_format=YES 53 # 54 # Make sure PORT transfer connections originate from port 20 (ftp-data). 55 connect_from_port_20=YES 56 # 57 # If you want, you can arrange for uploaded anonymous files to be owned by 58 # a different user. Note! Using "root" for uploaded files is not 59 # recommended! 60 #chown_uploads=YES 61 #chown_username=whoever 62 # 63 # You may change the default value for timing out an idle session. 64 #idle_session_timeout=600 65 # 66 # You may change the default value for timing out a data connection. 67 #data_connection_timeout=120 68 # 69 # It is recommended that you define on your system a unique user which the 70 # ftp server can use as a totally isolated and unprivileged user. 71 #nopriv_user=ftpsecure 72 # 73 # Enable this and the server will recognise asynchronous ABOR requests. Not 74 # recommended for security (the code is non-trivial). Not enabling it, 75 # however, may confuse older FTP clients. 76 #async_abor_enable=YES 77 # 78 # By default the server will pretend to allow ASCII mode but in fact ignore 79 # the request. Turn on the below options to have the server actually do ASCII 80 # mangling on files when in ASCII mode. 81 # Beware that on some FTP servers, ASCII support allows a denial of service 82 # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd 83 # predicted this attack and has always been safe, reporting the size of the 84 # raw file. 85 # ASCII mangling is a horrible feature of the protocol. 86 #ascii_upload_enable=YES 87 #ascii_download_enable=YES 88 # 89 # You may fully customise the login banner string: 90 #ftpd_banner=Welcome to blah FTP service. 91 # 92 # You may specify a file of disallowed anonymous e-mail addresses. Apparently 93 # useful for combatting certain DoS attacks. 94 #deny_email_enable=YES 95 # (default follows) 96 #banned_email_file=/etc/vsftpd/banned_emails 97 # 98 # You may specify an explicit list of local users to chroot() to their home 99 # directory. If chroot_local_user is YES, then this list becomes a list of100 # users to NOT chroot().101 chroot_local_user=YES102 #chroot_list_enable=YES103 # (default follows)104 #chroot_list_file=/etc/vsftpd/chroot_list105 #106 # You may activate the "-R" option to the builtin ls. This is disabled by107 # default to avoid remote users being able to cause excessive I/O on large108 # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume109 # the presence of the "-R" option, so there is a strong case for enabling it.110 #ls_recurse_enable=YES111 #112 # When "listen" directive is enabled, vsftpd runs in standalone mode and113 # listens on IPv4 sockets. This directive cannot be used in conjunction114 # with the listen_ipv6 directive.115 listen=YES116 #117 # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6118 # sockets, you must run two copies of vsftpd with two configuration files.119 # Make sure, that one of the listen options is commented !!120 #listen_ipv6=YES121  122 pam_service_name=vsftpd123 userlist_enable=YES124 userlist_deny=NO125 #userlist_enable 與userlist_deny同時使用方可生效,deny為YES時userlist檔案中的使用者無法登入ftp,相反則僅允許檔案中的使用者登入ftp126 tcp_wrappers=YES127 #max_clients=300128 #設定同時訪問FTP的最大用戶端數量129 #max_per_ip=10130 #設定單個IP地址同時串連FTP服務的最大數

設定完畢後重啟vsftpd服務

service vsftpd restart

建立ftp登入使用者:

useradd -d /ftp/ftpuser/ -s /sbin/nologin ftpuser #建立使用者,設定起家目錄為/ftp/ftpuser,預設shell為/sbin/nologin (因為預設該使用者是不允許登入linux系統的)echo "passwd" |passwd --stdin ftpuser #設定ftpuser使用者密碼為passwd

在 設定檔124行使用了userlist_deny=NO選項,則無論匿名使用者anonymous是否啟用都是無法登入的,這時候如果需要登入則需要配置/etc/vsftpd/目錄下的user_list檔案,將需要登入ftp伺服器的使用者加入其中即可。

將之前添加的ftpuser使用者添加到user_list檔案中即可登入。

一個較為簡單的ftp伺服器就搭建完畢了,查閱網上一些資料說ftp驗證過程都是明文的安全性會差一些,過後再慢慢加吧,先滿足需求後續修改吧(主要是還沒搞明白加密o(╯□╰)o)。


本文出自 “積小流,成江海” 部落格,請務必保留此出處http://goodjoe.blog.51cto.com/9173556/1771256

centos 搭建FTP伺服器

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.