1. ZZSRV2上的FTP配置
1.1. 安装FTP
# yum -y install ftp vsftpd
安装了两个包
ftp-0.17-66.el7.x86_64
vsftpd-3.0.2-9.el7.x86_64
# rpm -qa | grep db4-utils
# yum -y install db4-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.grandcloud.cn
* extras: mirrors.btte.net
* updates: mirrors.grandcloud.cn
No package db4-utils available.
Error: Nothing to do
不叫这个名字了?
# find / -name "db_load"
/usr/bin/db_load
# rpm -qf /usr/bin/db_load
libdb-utils-5.3.21-17.el7_0.1.x86_64
1.2. 配置
# mkdir /ftp/open
做几个测试文件
# echo opentest > /ftp/open/open.txt
# echo filetest > /tmp/filetest1.txt
# touch /ftp/open/anontest.txt
# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
# cd /etc/vsftpd/
# cp vsftpd.conf vsftpd.conf.origin
创建密码明文文件
# vi /etc/vsftpd/vftpuser.txt
alice
P@ssw0rd
jack
P@ssw0rd
tom
P@ssw0rd
根据明文创建密码DB文件
# db_load -T -t hash -f /etc/vsftpd/vftpuser.txt \
/etc/vsftpd/vftpuser.db
查看密码数据文件
# file /etc/vsftpd/vftpuser.db
/etc/vsftpd/vftpuser.db: Berkeley DB (Hash, version 9, native byte-order)
创建vftpd的guest账户
# useradd -d /ftp/private -s /sbin/nologin vftpuser
# vi /etc/pam.d/vsftpd
将auth及account的所有配置行行均注释掉,添加如下内容:
auth required pam_userdb.so db=/etc/vsftpd/vftpuser
account required pam_userdb.so db=/etc/vsftpd/vftpuser
# vi /etc/vsftpd/vsftpd.conf
在最后添加
anon_root=/ftp/open
virtual_use_local_privs=YES
guest_enable=YES
guest_username=vftpuser
chroot_local_user=YES
allow_writeable_chroot=YES
# systemctl enable vsftpd
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'
# systemctl start vsftpd
# systemctl status vsftpd
vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
Active: active (running) since Mon 2014-08-11 19:57:12 CST; 22h ago
Main PID: 12733 (vsftpd)
CGroup: /system.slice/vsftpd.service
a””a”12733 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
systemd[1]: Starting Vsftpd ftp daemon...
systemd[1]: Started Vsftpd ftp daemon.
vsftpd[12738]: pam_userdb(vsftpd:auth): user 'alice' granted access
vsftpd[12753]: pam_userdb(vsftpd:auth): user 'jack' granted access
systemd[1]: Started Vsftpd ftp daemon.
1.3. 测试
测试匿名账户
# ftp localhost
Trying ::1...
Connected to localhost (::1).
220 (vsFTPd 3.0.2)
Name (localhost:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||61057|).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 9 Aug 11 11:45 open.txt
226 Directory send OK.
ftp> lcd /tmp
Local directory now /tmp
ftp> get open.txt
local: open.txt remote: open.txt
229 Entering Extended Passive Mode (|||64276|).
150 Opening BINARY mode data connection for open.txt (9 bytes).
226 Transfer complete.
9 bytes received in 0.000895 secs (10.06 Kbytes/sec)
ftp> bye
221 Goodbye.
# ftp localhost
Trying ::1...
Connected to localhost (::1).
220 (vsFTPd 3.0.2)
Name (localhost:root): alice
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||21750|).
150 Here comes the directory listing.
226 Directory send OK.
ftp> !ls /tmp
filetest1.txt open.txt systemd-private-9xPN7y vmware-fonts0 vmware-installer1 vmware-root vmware-tools-distrib
ks-script-_Yi85R SAMBA.docx vmware-config0 vmware-installer0 vmware-installer2 vmware-root-2117481760 yum.log
ftp> lcd /tmp
Local directory now /tmp
ftp> put filetest1.txt
local: filetest1.txt remote: filetest1.txt
229 Entering Extended Passive Mode (|||65399|).
150 Ok to send data.
226 Transfer complete.
9 bytes sent in 5.9e-05 secs (152.54 Kbytes/sec)
ftp> bye
221 Goodbye.