您好,登錄后才能下訂單哦!
簡介:
安全性是編寫VSFTP的初衷,除了這與生俱來的安全特性以外,高速與高穩定性也是VSFTP的兩個重要特點。
在速度方面,使用ASCII代碼的模式下載數據時,VSFTP的速度是Wu-FTP的兩倍,如果Linux主機使用2.4.*的內核,在千兆以太網上的下載速度可達86MB/S。
在穩定方面,VSFTP就更加的出色,VSFTP在單機(非集群)上支持4000個以上的并發用戶同時連接,根據Red Hat的Ftp服務器的數據,VSFTP服務器可以支持15000個并發用戶
實驗環境:
OS: CentOS 6.6[root@1inux htdocs]# yum -y install vsftpd Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package vsftpd.x86_64 0:2.2.2-12.el6_5.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================= Installing: vsftpd x86_64 2.2.2-12.el6_5.1 CD 151 k Transaction Summary ========================================================================================================================================= Install 1 Package(s) Total download size: 151 k Installed size: 331 k Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : vsftpd-2.2.2-12.el6_5.1.x86_64 1/1 Verifying : vsftpd-2.2.2-12.el6_5.1.x86_64 1/1 Installed: vsftpd.x86_64 0:2.2.2-12.el6_5.1 Complete! [root@1inux htdocs]#2、查看vsftp安裝后生成的文件:
[root@1inux htdocs]# rpm -ql vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd //用戶認證配置文件 /etc/rc.d/init.d/vsftpd //服務腳本 /etc/vsftpd //配置文件目錄 /etc/vsftpd/vsftpd.conf //配置文件 /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd_conf_migrate.sh /usr/sbin/vsftpd //主程序 ..... /var/ftp //匿名訪問目錄 /var/ftp/pub
3、安裝完成后啟動vsftp
[root@1inux htdocs]# service vsftpd start Starting vsftpd for vsftpd: [ OK ] [root@1inux htdocs]#=========================
匿名登錄方式: (1)可以輸入用戶名ftp,密碼為空,然后登陸 (2) 用戶名、密碼都是anonymous
ftp> help //CentOS ftp客戶端可以使用help命令獲取命令列表 ! debug mdir sendport site $ dir mget put size account disconnect mkdir pwd status append exit mls quit struct ascii form mode quote system bell get modtime recv sunique binary glob mput reget tenex bye hash newer rstatus tick case help nmap rhelp trace cd idle nlist rename type cdup p_w_picpath ntrans reset user chmod lcd open restart umask close ls prompt rmdir verbose cr macdef passive runique ? delete mdelete proxy send ftp>主要命令介紹:
注意:配置之前先對其配置文件進行備份,以防止造成無法挽回的損失 # cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
anonymous_enable=NO
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 530 Login incorrect. Login failed. //訪問失敗 ftp>2、增加匿名用戶上傳權限
ftp> put fstab local: fstab remote: fstab 227 Entering Passive Mode (172,16,66,82,148,217). 553 Could not create file. //還是提示無法創建, 這是因為vsftp服務是以ftp用戶啟動的其對對/var/ftp目錄沒有寫權限解決方案:在/var/ftp/目錄下創建一個目錄更改其權限使ftp用戶對其有讀寫權限:
[root@1inux vsftpd]# mkdir /var/ftp/upload/ [root@1inux vsftpd]# cd /var/ftp/ [root@1inux ftp]# setfacl -m u:ftp:rwx upload/ [root@1inux ftp]# getfacl upload/ # file: upload/ # owner: root # group: root user::rwx user:ftp:rwx group::r-x mask::rwx other::r-x接下來我們再上傳文件試試
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (172,16,66,82,201,178). 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 Aug 04 2014 pub drwxrwxr-x 2 0 0 4096 May 01 20:43 upload 226 Directory send OK. ftp> cd upload 250 Directory successfully changed. ftp> lcd /etc Local directory now /etc ftp> put fstab local: fstab remote: fstab 227 Entering Passive Mode (172,16,66,82,47,38). 150 Ok to send data. 226 Transfer complete. 1127 bytes sent in 0.000133 secs (8473.68 Kbytes/sec) ftp> ls 227 Entering Passive Mode (172,16,66,82,233,197). 150 Here comes the directory listing. -rw------- 1 14 50 1127 May 01 20:52 fstab //文件已經存在 226 Directory send OK. ftp>3、創建目錄:
[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ] [root@1inux vsftpd]#在客戶端匿名登錄創建目錄anontest
ftp> mkdir anontest 257 "/upload/anontest" created //提示創建成功 ftp> ls 227 Entering Passive Mode (172,16,66,82,41,121). 150 Here comes the directory listing. drwx------ 2 14 50 4096 May 01 21:02 anontest //目錄已經存在 -rw------- 1 14 50 1127 May 01 20:52 fstab 226 Directory send OK. ftp>4、刪除文件或目錄
ftp> ls 227 Entering Passive Mode (172,16,66,82,233,251). 150 Here comes the directory listing. drwx------ 2 14 50 4096 May 01 21:02 anontest -rw------- 1 14 50 1127 May 01 20:52 fstab 226 Directory send OK. ftp> delete fstab //刪除文件 250 Delete operation successful. ftp> rmdir anontest //刪除目錄 250 Remove directory operation successful. ftp> ls 227 Entering Passive Mode (172,16,66,82,237,22). 150 Here comes the directory listing. 226 Directory send OK. ftp>
[root@1inux vsftpd]# useradd admin [root@1inux vsftpd]# passwd admin Changing password for user admin. New password: BAD PASSWORD: it is WAY too short BAD PASSWORD: is a palindrome Retype new password: passwd: all authentication tokens updated successfully. [root@1inux vsftpd]#1.2、訪問
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (172,16,66,82,236,21). 150 Here comes the directory listing. 226 Directory send OK. ftp> pwd 257 "/home/admin" //使用系統用戶登陸默認訪問的是其家目錄 ftp> lcd /root //切換本地目錄 ftp> pwd 257 "/etc"----------------------
[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ] [root@1inux vsftpd]#2.1、訪問:
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 530 This FTP server is anonymous only. Login failed. //輸入用戶名后 直接提示失敗 ftp>
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> lcd /etc Local directory now /etc ftp> ls 227 Entering Passive Mode (172,16,66,82,171,255). 150 Here comes the directory listing. drwxr-xr-x 2 501 501 4096 May 01 21:24 abc 226 Directory send OK.4、鎖定部分用戶至其家目錄,可以啟用以下行:
[root@1inux vsftpd]# useradd centos [root@1inux vsftpd]# echo "1" | passwd --stdin centos [root@1inux vsftpd]# useradd fedora [root@1inux vsftpd]# echo "1" | passwd --stdin fedora [root@1inux vsftpd]#4.2、創建用戶列表
[root@1inux vsftpd]# vim chroot_list [root@1inux vsftpd]# cat chroot_list centos4.3、重新加載配置文件
[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ]4.4、登陸查看
1、以centos身份登陸 [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): centos 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> 2、以fedora身份 登陸 [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): fedora 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/home/fedora"
# vim .message Hello, guest How are you?重載配置文件:# service vsftpd reload
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd upload 250-Hello, guest //已經提示剛才定義的消息 250-How are you? 250 Directory successfully changed. ftp>2、日志相關
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. //登陸時顯示 Name (172.16.66.82:root):
7、vsftpd使用pam完成用戶認證,其用到的pam配置文件
/etc/pam.d/vsftpd //定義了用戶訪問vsftpd時用哪個模塊對用戶做認證# cat /etc/pam.d/vsftpd %PAM-1.0 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-------------------
_______/etc/pam.d/vsftpd ______________ auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed-------------------------------------------------------------------------------------------
/etc/vsftpd/ftpusers 存放拒絕訪問vsftp的用戶列表,用戶名一旦在此文件中出現,其將會被禁止訪問vsftp
eg: 服務器端: [root@1inux vsftpd]# echo "admin" >> ftpusers [root@1inux vsftpd]# service vsftpd reload 客戶端: [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): admin 331 Please specify the password. Password: 530 Login incorrect. Login failed. //登陸失敗 ftp>
8、控制用戶列表文件
/etc/vsftpd/user_list# echo "centos" >> /etc/vsftpd/user_list [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): centos 530 Permission denied. //被拒絕訪問 Login failed. ftp> ------eg2:
[root@1inux vsftpd]# cat user_list # vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody centos [root@1inux vsftpd]# 客戶端: [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): fedora 530 Permission denied. //fedora 用戶直接被拒絕 Login failed. ftp> bye 221 Goodbye. [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): centos 331 Please specify the password. Password: 230 Login successful. //centos 用戶可以訪問 Remote system type is UNIX. Using binary mode to transfer files. ftp>
OK 虛擬用戶及系統用的的配置基本上就這么些......歡迎補充
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。