标签:vsftp
实验拓扑:
Linux Client
-----RHEL5.9(vmnet1)----------(vmnet1)
Win7 Client
实验一:测试默认安装vsftpd的结果
匿名用户与本地用户都可以登录
匿名用户登录到/var/ftp,只能下载不能上传
本地用户登录到本地用户的家目录,可以上传和下载
[root@dhcpser ~]# rpm -q vsftpd
package vsftpd is not installed
[root@dhcpser ~]# cd /misc/cd/Server
[root@localhost Server]# ls *vsftpd*
vsftpd-2.0.5-28.el5.x86_64.rpm
[root@localhost Server]# rpm -ivh vsftpd-2.0.5-28.el5.x86_64.rpm
[root@localhost Server]# service vsftpd restart
关闭 vsftpd: [失败]
为 vsftpd 启动 vsftpd: [确定]
[root@localhost Server]# service vsftpd restart
关闭 vsftpd: [确定]
为 vsftpd 启动 vsftpd: [确定]
[root@localhost Server]# chkconfig vsftpd on
[root@localhost ~]# ls -lh /etc > /var/ftp/pub/etc.txt
[root@localhost ~]# useradd kaka
[root@localhost ~]# echo "123456" | passwd --stdin kaka
Changing password for user kaka.
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
验证:(客户端测试)
[root@localhost ~]# ftp 192.168.10.253
Connected to 192.168.10.253.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.10.253:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (192,168,10,253,75,98)
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 11627 Jun 13 02:04 etc.txt
226 Directory send OK.
ftp> get etc.txt
local: etc.txt remote: etc.txt
227 Entering Passive Mode (192,168,10,253,136,141)
150 Opening BINARY mode data connection for etc.txt (11627 bytes).
226 File send OK.
11627 bytes received in 0.00082 seconds (1.4e+04 Kbytes/s)
ftp> !ls
anaconda-ks.cfg etc.txt install.log.syslog
Desktop install.log
ftp> put install.log
local: install.log remote: install.log
227 Entering Passive Mode (192,168,10,253,46,17)
550 Permission denied.
ftp> quit
[root@localhost ~]# lftp 192.168.10.253
lftp 192.168.10.253:~> user kaka
口令:
lftp kaka@192.168.10.253:~> put install.log
实验二
禁止匿名用户登录
修改FTP默认端口为2121
禁锢本地用户在自己家目录
实验步骤:
[root@ser01 ~]# cd /etc/vsftpd/
[root@ser01 vsftpd]# cp vsftpd.conf vsftpd.conf.bak
[root@ser01 vsftpd]# vim vsftpd.conf
12 anonymous_enable=NO
119 listen_port=2121
120 chroot_local_user=YES
[root@ser01 vsftpd]# service vsftpd restart
[root@ser01 vsftpd]# netstat -tulnp | grep vsftpd
tcp 0 0 0.0.0.0:2121 0.0.0.0:* LISTEN 4705/vsftpd
实验三:验证黑/白名单
/etc/vsftpd/ftpusers黑名单
/etc/vsftpd/user_list
[root@ser01 ~]# useradd jerry
[root@ser01 ~]# useradd mike
[root@ser01 ~]# echo "redhat" | passwd --stdin jerry
Changing password for user jerry.
passwd: all authentication tokens updated successfully.
[root@ser01 ~]# echo "redhat" | passwd --stdin mike
Changing password for user mike.
passwd: all authentication tokens updated successfully.
[root@ser01 ~]# grep kaka /etc/vsftpd/ftpusers
kaka
//请问kaka能否登录FTP???
[root@ser01 ~]# grep jerry /etc/vsftpd/user_list
jerry
//请问jerry能否登录FTP???
[root@ser01 ~]# vim /etc/vsftpd/vsftpd.conf
...
121 userlist_deny=NO
[root@ser01 ~]# service vsftpd restart
实验四:
本地用户登录到/data/ftproot目录
up上传/下载,down仅下载。拒绝所有用户登录包括匿名用户
最多20个并发,每IP地址最多2个并发
限制下载速度限制为100KB/s
[root@ser01 ~]# mkdir -p /data/ftproot
[root@ser01 ~]# useradd up
[root@ser01 ~]# useradd down
[root@ser01 ~]# echo "redhat" | passwd --stdin up
[root@ser01 ~]# echo "redhat" | passwd --stdin down
[root@ser01 ~]# vim /etc/vsftpd/vsftpd.conf
...
12 anonymous_enable=NO
...
18 write_enable=YES
...
117 userlist_enable=YES
...
121 userlist_deny=NO
122 local_root=/data/ftproot
123 max_clients=20
124 max_per_ip=2
125 local_max_rate=100000
[root@ser01 ~]# service vsftpd restart
[root@ser01 ~]# setfacl -m u:up:rwx /data/ftproot/
[root@ser01 ~]# tail -n 2 /etc/vsftpd/user_list
up
down
[root@ser01 ~]# dd if=/dev/zero of=/data/ftproot/local.tgz bs=1M count=1000
测试:
[root@localhost ~]# wget ftp://up:redhat@192.168.10.253:2121/local.tgz
本文出自 “一饮寂寞” 博客,转载请与作者联系!
标签:vsftp
原文地址:http://lowlife.blog.51cto.com/9042241/1427084