|
搭建实验环境: 服务器部分:
[root@localhost /]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:26:05:59
inet addr:1.1.1.1 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe26:559/64 Scopeink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:12294 (12.0 KiB)
Interrupt:59 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9322 errors:0 dropped:0 overruns:0 frame:0
TX packets:9322 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:72769156 (69.3 MiB) TX bytes:72769156 (69.3 MiB)
客户机部分:
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:AC:AF:AD
inet addr:1.1.1.2 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feac:afad/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37 errors:0 dropped:0 overruns:0 frame:0
TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7367 (7.1 KiB) TX bytes:19115 (18.6 KiB)
Interrupt:59 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
[root@localhost ~]# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.883 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=0.511 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=0.481 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=64 time=0.452 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=64 time=0.696 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=64 time=0.559 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=64 time=0.493 ms
--- 1.1.1.1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6171ms
rtt min/avg/max/mdev = 0.452/0.582/0.883/0.144 ms
搭建服务:
1、安装FTP软件包
[root@localhost /]# mount -o loop /dev/cdrom /media
[root@localhost /]# rpm -ivh /media/Server/vsftpd-2.0.5-16.el5_4.1.i386.rpm
error: failed to stat /media/RHEL_5.5 i386 DVD: 没有那个文件或目录
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]
2、创建虚拟用户
[root@localhost /]# vim /etc/vsftpd/vusers.list
[root@localhost /]# cat /etc/vsftpd/vusers.list
devadm
123
sales
123
saleadm
123
3、建立虚拟用户数据库
[root@localhost /]# cd /etc/vsftpd/
[root@localhost vsftpd]# rpm -ivh /media/Server/db4-utils-4.3.29-10.el5.i386.rpm
error: failed to stat /media/RHEL_5.5 i386 DVD: 没有那个文件或目录
Preparing... ########################################### [100%]
1:db4-utils ########################################### [100%]
[root@localhost vsftpd]# db_load -T -t hash -f vusers.list vusers.db
[root@localhost vsftpd]# file vusers.db
vusers.db: Berkeley DB (Hash, version 8, native byte-order)
[root@localhost vsftpd]# chown 600 /etc/vsftpd/vusers.*
4、建立映射用户、目录以及测试文件
[root@localhost vsftpd]# useradd -d /var/market -s /sbin/nologin virtual
[root@localhost vsftpd]# chmod 755 /var/market
[root@localhost vsftpd]# touch vutest.file
[root@localhost vsftpd]# mkdir /var/ftp/soft
[root@localhost vsftpd]# cp vu
vusers.db vusers.list vutest.file
[root@localhost vsftpd]# cp vutest.file /var/market/
[root@localhost vsftpd]# cp vutest.file /var/ftp/soft/test.file
[root@localhost vsftpd]# chown virtual /var/ftp/soft/
[root@localhost vsftpd]# cd /var/ftp/
[root@localhost ftp]# ls
pub soft
[root@localhost ftp]# ll
总计 16
drwxr-xr-x 2 root root 4096 2009-12-04 pub
drwxr-xr-x 2 virtual root 4096 03-08 03:35 soft
5、建立虚拟用户PAM认证文件
[root@localhost ftp]# vim /etc/pam.d/vsftpd.vu
[root@localhost ftp]# cat /etc/pam.d/vsftpd.vu
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/vusers
account required pam_userdb.so db=/etc/vsftpd/vusers
6、修改/etc/vsftpd/vsftpd.conf,添加虚拟用户支持,带宽限制
anonymous_enable=YES
anon_root=/var/ftp/soft
local_enable=YES
anon_umask=022
write_enable=YES
guest_enable=YES
guest_username=virtual
user_config_dir=/etc/vsftpd/vusers_dir
max_clients=150
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
pam_service_name=vsftpd.vu
userlist_enable=YES
tcp_wrappers=YES
[root@localhost vusers_dir]# service vsftpd restart
关闭 vsftpd: [确定]
为 vsftpd 启动 vsftpd: [确定]
7、为用户建立单独的配置文件
[root@localhost ftp]# mkdir /etc/vsftpd/vusers_dir
[root@localhost ftp]# cd /etc/vsftpd/vu
vusers.db vusers_dir/ vusers.list vutest.file
[root@localhost ftp]# cd /etc/vsftpd/vusers_dir/
[root@localhost vusers_dir]# touch sales
[root@localhost vusers_dir]# vim devadm
[root@localhost vusers_dir]# cat devadm
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_max_rate=500000
local_root=/var/ftp/soft
[root@localhost vusers_dir]# vim saleadm
[root@localhost vusers_dir]# cat saleadm
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_max_rate=50000
[root@localhost vusers_dir]# service vsftpd restart
关闭 vsftpd: [确定]
为 vsftpd 启动 vsftpd: [确定]
8、实验结束,去客户端验证
|
|