1)安裝問題html
vsftp屬於linux自帶的service,所以在安裝linux的時候就能夠勾選安裝,若是當時未安裝,後來又須要,那麼能夠找出原始安裝iso文件,提取/Packages路徑下面的rpm進行安裝,建議不要隨便在網上找rpm,由於rpm可能會跟本身的linux不兼容,而報錯,好比說是libcrypto.so.4找不到,若是是tar.gz安裝make的時候可能會報找不到cap_init,總之就是依賴問題很差解決,所以最好仍是去安裝光盤裏面找原配的rpm進行安裝。若是服務端能訪問外網,也建議用yum安裝。yum能自動下載安裝包之間的依賴包,省去因爲依賴包產生的麻煩。linux
2)簡單使用(使用/etc/vsftpd/vsftpd.conf的默認配置)shell
啓動ftp命令:[root@localhost]# service vsftpd start windows
查看ftp狀態命令:[root@localhost]# service vsftpd status 安全
重啓ftp命令:[root@localhost]# service vsftpd restart session
關閉ftp命令:[root@localhost]# service vsftpd stopapp
默認狀況下,只須要把公共文件放在/var/ftp,匿名用戶就能夠免登陸下載了。socket
3)簡要說明下vsftp的相關信息async
/usr/sbin/vsftpd ---- VSFTPD的主程序tcp
/etc/rc.d/init.d/vsftpd ---- 啓動腳本
/etc/vsftpd/vsftpd.conf ---- 主配置文件
/etc/pam.d/vsftpd ---- PAM認證文件
/etc/vsftpd.ftpusers ---- 禁止使用VSFTPD的用戶列表文件
/etc/vsftpd.user_list ---- 禁止或容許使用VSFTPD的用戶列表文件
/var/ftp ---- 匿名用戶主目錄
/var/ftp/pub ---- 匿名用戶的下載目錄
4)異常處理
有的文件可能會下載失敗,這裏如下載dd.conf失敗做爲例子,
失敗的緣由是權限不夠,以下,
[root@localhost ftp]# ll 總用量 130640 -rw-r--r--. 1 liyang liyang 379 9月 28 15:40 2.txt -rw-------. 1 root root 4567 9月 28 15:38 dd.conf -rw-------. 1 root root 125 3月 4 2011 ftpusers -rw-r--r--. 1 liyang liyang 17473536 9月 28 15:19 help_20140313_v1.0.doc
解決方法是賦權限,之後再下載就正常了。
[root@localhost ftp]# chmod 777 dd.conf
5)經過/etc/vsftpd/vsftpd.conf配置ftp用戶進行上傳
5.1 ftp的用戶帳戶是借用了linux系統用戶的帳戶,根據這個規則,本人建立系統用戶ftpadmin,密碼爲peidian1#,
[root@localhost ayu]# useradd -d /var/common -s /sbin/nologin ftpadmin [root@localhost ayu]# passwd ftpadmin 更改用戶 ftpadmin 的密碼 。 新的 密碼: 從新輸入新的 密碼: passwd: 全部的身份驗證令牌已經成功更新。
這裏簡單註明下密碼設置問題,linux的密碼安全機制要求密碼須要有必定的複雜度,這裏就不深刻研究。另外,/sbin/nologin這裏是限制了ftpadmin這個用戶沒有系統登陸的權限,只能用做ftp登陸。最後,-d設置了ftpadmin用戶的「家目錄」/var/common,若是命令爲useradd -s /sbin/nologin ftpadmin,那麼「家目錄」默認就是/home/ftpadmin
5.2)防火牆(iptables)限制訪問的問題
關閉iptables服務,執行service iptables stop,再查看是否關閉成功執行service iptables status
5.3)SELinux的問題
須要執行一行命令,[root@localhost]#setsebool -P ftp_home_dir on,而後查看 SELinux 的狀態: sestatus -b | grep ftp,確保ftp_home_dir狀態爲on。重啓ftp服務 [root@localhost]# service vsftpd restart,不然會發生500 OOPS child died或者是200 PORT command successful. Consider using PASV.553 Could not create file.問題都是SELinux引發的。
關閉SELinux,vi /etc/sysconfig/selinux,修改成SELINUX=disabled,重啓便可,若是不但願重啓那麼能夠執行setenforce 0,不過這種方式只是本次生效。
配置完SELinux後就能夠進行上傳操做了。用戶名:ftpadmin,密碼:peidian1#,上傳的路徑爲/var/common
5.4)上傳文件字符集編碼的問題(文件名帶中文上傳後亂碼問題)
Windows的字符集編碼是GBK/GB18030,而Linux使用utf8編碼,所以在上傳帶有中文字符文件名的文件時,就會發生文件名亂碼的問題。建議不要爲此去修改linux的字符集編碼,由於「全盤顛覆」的話的會得不償失。解決方案是用ftp客戶端工具,客戶端工具代理上傳下載規定編碼爲UTF8就不會出現亂碼的問題。
給出FlashFXP下載地址:http://pan.baidu.com/s/1hqvYQwO
點擊「鏈接」按鈕便可連上,能夠在log信息欄看到字符集編碼默認爲UTF8,不須要另外設置,以下,
5.5)ftp用戶(如ftpadmin)上傳文件到匿名下載目錄的問題
這裏須要特別注意,若是僅僅把匿名訪問目錄設置爲/var/common,那麼會出現匿名訪問時被強制要求輸入用戶名/密碼的狀況,通過本人的不斷嘗試總結出一種方法來(暫時沒法解釋緣由),但能夠實現權限用戶ftp上傳到匿名訪問目錄的效果。
1.用root用戶建立一個目錄/var/ftpcommon
2.執行chown ftpadmin:ftpadmin /var/ftpcommon,也就是將路徑/var/ftpcommon的全部者由root轉給ftpadmin
3.配置匿名訪問目錄和權限用戶訪問目錄爲/var/ftpcommon,附上本人配置好的/etc/vsftpd/vsftpd.conf,其實也就是在默認配置增長了
anon_root=/var/ftpcommon local_root=/var/ftpcommon chroot_local_user=YES
,完整配置以下,
# 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. 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. # Note that the default log file location is /var/log/xferlog in this case. 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 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_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list anon_root=/var/ftpcommon local_root=/var/ftpcommon chroot_local_user=YES # # 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 # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES
對配置的說明:
# 禁止匿名用戶anonymous登陸
anonymous_enable=YES
# 容許本地用戶登陸
local_enable=YES
# 讓登陸的用戶有寫權限(上傳,刪除)
write_enable=YES
更改匿名用戶和登陸用戶(這裏主要用於ftpadmin)默認目錄,
anon_root=/var/ftpcommon
local_root=/var/ftpcommon
chroot_local_user=YES
anon_root表示匿名用戶登陸到ftp時的默認目錄,local_root表示使用本地用戶登陸到ftp時的默認目錄,chroot_local_user表示限制登陸用戶登陸後只能訪問本身的「家目錄」,而這裏全部用戶的家目錄都被統一設置爲/var/ftpcommon。這裏有一篇帖子助於瞭解關於chroot_local_user:http://blog.csdn.net/bluishglc/article/details/42398811
5.6)用cmd命令行訪問ftp有助於排錯,ftp訪問失敗時,windows客戶端錯誤提示信息遠遠不如cmd命令提示全面
準確,經常使用cmd訪問ftp命令以下,
1.登陸命令,輸入"ftp 210.10.3.61"或者輸入"ftp"回車,再輸入"open 210.10.3.61"
2.匿名登陸,輸入"anonymous",要求輸入密碼時直接敲回車;權限用戶登陸,輸入用戶名/密碼
3.查看文件列表,輸入"dir",查看本地文件列表請輸入"!dir"
4.上傳,輸入"put 文件名";下載,輸入"get 文件名"
5.切換路徑輸入"cd 路徑名"
除了本博客提到的這些,vsftp還有可配置匿名用戶上傳但不能刪除的,還可配置虛擬ftp用戶,而後能用mount掛載的方式,這些有待進一步研究,使用cmd命令行去進行ftp的get和put操做也是有意思的,這些也須要記錄,可是目前時間有限。http://jingyan.baidu.com/article/0bc808fc8778ee1bd485b93b.html
http://www.linuxeden.com/html/netadmin/20120101/118712.html
http://www.linuxidc.com/Linux/2010-03/24798.htm(mount掛載??)
http://www.jbxue.com/article/2928.html
http://blog.chinaunix.net/uid-28898468-id-4273229.html
添加chroot_list:http://blog.sina.com.cn/s/blog_4b93170a0100mdm3.html
比較全:http://blog.sina.com.cn/s/blog_715b47c50101k1bx.html
http://andyzhao.blog.51cto.com/794987/183617
iptables??http://www.open-open.com/lib/view/open1413513821934.html