安裝主機:192.168.0.25linux
rpm -qa | grep vsftpdvim
yum -y install vsftpd服務器
vi /etc/vsftpd/vsftpd.conf 修改下面配置app
anonymous_enable=NO (不容許匿名用戶登錄) local_enable=YES (容許本地用戶登陸) write_able=YES (容許讀寫操做) xferlog_enable=YES (啓動上傳/下載功能) ascii_upload_enable=YES (啓用ascii模式上傳數據) ascii_download_enable=YES(啓用ascii模式下載數據) chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/logins.txt(這三行容許logins.txt用戶能夠切換到別的目錄) guest_enable=YES(啓用虛擬用戶) guest_username=manager(將虛擬用戶映射爲本地manager用戶) virtual_use_local_privs=YES (虛擬用戶與本地用戶權限相同) pasv_promiscuous=YES pasv_enable=YES (開啓PASV工做模式) pam_service_name=vsftpd.vu(指定PAM配置文件) user_config_dir=/etc/vsftpd/user_conf (指定用戶配置文件所在的目錄) userlist_enable=YES tcp_wrappers=YES (控制主機和用戶訪問)
在/etc/pam.d/中修改文件vsftpd.vu,若是沒有此文件,則touch vsftpd.vu建立
增長下列內容:
auth required pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required pam_userdb.so db=/etc/vsftpd/vsftpd_logintcp
新建touch /etc/vsftpd/ logins.txt文件,添加用戶(根據須要新建不一樣用戶)。
按照一行用戶名一行密碼排列ide
esop esop
創建訪問者數據文件(若是沒有能夠安裝:yum install db4-utils)
touch vsftpd_login
touch vsftpd_login.db測試
db_load -T -t hash -f /etc/vsftpd/logins.txt /etc/vsftpd/vsftpd_login.dbui
/data/manager/inputFiledebug
mkdir /etc/vsftpd/user_confrest
在/etc/vsftpd/user_conf目錄中建立以用戶名命名的配置文件esop
touch esop,增長如下配置
local_root=/data/manager/inputFile write_enable=YES anon_mkdir_write_enable=YES anon_upload_enable=YES anon_other_write_enable=YES anon_umask=022
touch /etc/vsftpd/ftpusers
touch /etc/vsftpd/ user_list
把不容許訪問的用戶寫入這兩個文件裏,一行一個用戶
[root@zqyz91 vsftpd]# vim ftpusers
#Users that are not allowed to login via ftp root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody
啓動vsftp服務:
service vsftpd restart
中止vsftp服務:
service vsftpd stop
重啓vsftp服務:
service vsftpd restart
設置開機自啓動
chkconfig vsftpd on
ftp 192.168.0.25
輸入帳號:esop
密碼:esop
若提示沒有此命令,則安裝ftp
yum provides ftp
yum -y install ftp
經常使用命令
ftp> help Commands may be abbreviated. Commands are: ! 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 image ntrans reset user chmod lcd open restart umask close ls prompt rmdir verbose cr macdef passive runique ? delete mdelete proxy send
[root@zqyz91 vsftpd]# ftp 192.168.0.25
Connected to 192.168.0.25 (192.168.0.25).
220 (vsFTPd 3.0.2)
Name (192.168.0.25:root): esop
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 (192,168,0,25,202,86).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1002 0 Oct 30 06:57 a.bak
drwxr-x--- 2 1001 1002 4096 Oct 30 07:45 esop
226 Directory send OK.
put 文件名
ftp> put text
local: text remote: text
227 Entering Passive Mode (192,168,0,25,32,6).
150 Ok to send data.
226 Transfer complete.
126527 bytes sent in 0.0134 secs (9438.09 Kbytes/sec)
get 文件名
ftp> get a.bak
local: a.bak remote: a.bak
227 Entering Passive Mode (192,168,0,25,123,43).
150 Opening BINARY mode data connection for a.bak (0 bytes).
226 Transfer complete.
ftp> quit
221 Goodbye.
問題: 500 OOPS: cannot change directory:/home/master
[root@localhost ~]# cat /etc/selinux/configSELINUX=enforcingselinxu=enforcing 改爲 selinux=disabled重啓服務器。