一、Windows访问vsftp

1、vsftp的安装

[root@zyx ~]# mkdir /mnt/cdrom   //建立光盘挂载点

[root@zyx ~]# mount /dev/cdrom /mnt/cdrom/   //挂载光盘
mount: block device /dev/cdrom is write-protected, mounting read-only

[root@zyx ~]# cd /mnt/cdrom/Server/
[root@zyx Server]# ll vsft*

image 

[root@zyx Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm   //安装vsftp

image

 

[root@zyx Server]# service vsftpd start        //启动vsftp服务        
Starting vsftpd for vsftpd:                                [  OK ]
[root@zyx Server]# chkconfig vsftpd on   //设为开机时启动

2、匿名帐号登录   anonymous

image

2、本地帐号登录

[root@zyx Server]# useradd user1   //新建用户user1
[root@zyx Server]# passwd user1    //设置密码
Changing password for user user1.   //新建用户user1
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@zyx Server]# cd /home/user1/ //切换到此目录下
[root@zyx user1]# ll
total 0
[root@zyx user1]# touch zyx  //生成文件zyx
[root@zyx user1]# ll
total 0
-rw-r--r-- 1 root root 0 Sep 12 11:17 zyx

4、user1 Windows登录

image

image

 

本地权限

[root@zyx ~]# ll -d /home/user1/
drwx------ 3 user1 user1 4096 Sep 12 11:17 /home/user1/   // /home/user1/的所属权限者是user1

image

网络权限

[root@zyx ~]# vim /etc/vsftpd/vsftpd.conf

image   //网络可写权限

[root@zyx ~]# service vsftpd restart
Shutting down vsftpd:                                      [ OK  ]
Starting vsftpd for vsftpd:                                [ OK  ]

匿名上传文件

image

[root@zyx ~]# ll -d /var/ftp/pub/
drwxr-xr-x 2 root root 4096 May 13  2009 /var/ftp/pub/   // /var/ftp/pub/ 的所有权限归管理员

匿名无权上传文件到服务器

image

 

[root@zyx ~]# chmod o+wt /var/ftp/pub/  //修改此目录的权限
[root@zyx ~]# ll -d /var/ftp/pub/
drwxr-xrwt 2 root root 4096 May 13  2009 /var/ftp/pub/ 

匿名有权限上传文件到服务器

image

匿名无权限删除服务器上的文件

image

匿名无权在服务器上新建文件

image

匿名无权重命名服务器上的文件

image

 

image

重启服务

[root@zyx ~]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

匿名有权在服务器上新建文件

image

image

[root@zyx ~]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

匿名有权重命名服务器上的文件

image

 

匿名有权删除服务器上的文件

image

image

匿名下载

image

[root@zyx ~]# cd /var/ftp/pub/
[root@zyx pub]# ll
total 0
-rw------- 1 ftp ftp 0 Sep 20 14:20 zyx.txt

[root@zyx pub]# chmod o+r zyx.txt  //修改文件权限
[root@zyx pub]# ll
total 0
-rw----r-- 1 ftp ftp 0 Sep 20 14:20 zyx.txt

匿名有权限下载服务器上的文件

image

成功下载

image

[root@zyx pub]# vim /etc/vsftpd/vsftpd.conf

image

[root@zyx pub]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

image

image

[root@zyx pub]# ll
total 0
-rw----r-- 1 ftp ftp 0 Sep 20 14:54 123.txt
-rw----r-- 1 ftp ftp 0 Sep 20 14:20 zyx.txt

二、linux访问vsftp

访问ftp服务器的方法

1、命令行

帮助?

dir 列远程的内容

! dir 列本地内容

cd 远程切换

lcd 本地切换

get 下载  mget 多个下载

put 上传  mput 多个上传

传递文件 ascii bin

2、浏览器

3、客户端软件

[root@zyx pub]# vim .message //编辑此文件,并写下一下内容

[root@zyx pub]# ftp 127.0.0.1

image

image

启动日志功能

image

image

[root@zyx pub]# service vsftpd restart //重启服务
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [ OK  ]

[root@zyx pub]# ll /var/log/vsftpd.log
-rw------- 1 root root 275 Sep 20 16:27 /var/log/vsftpd.log

注:

chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
只有放置到chroot——list中的帐号可以切换

 

chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
只有没有放置到chroot——list中的帐号可以切换

 匿名登录

[root@zyx pub]# ftp 127.0.0.1

image

[root@zyx pub]# echo "qq@sina.com">> /etc/vsftpd/banned_emails

[root@zyx ~]# vim /etc/vsftpd/vsftpd.conf

image 

[root@zyx pub]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

[root@zyx pub]# ftp 127.0.0.1

image

[root@zyx pub]# vim /etc/vsftpd/banned_emails

image

 

[root@zyx pub]# useradd user2
[root@zyx pub]# passwd user2
Changing password for user user2.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

 

[root@zyx pub]# ftp 192.168.88.200

image

image

image

image

[root@zyx pub]# vim /etc/vsftpd/chroot_list

image

[root@zyx pub]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

 

[root@zyx pub]# ftp 192.168.88.200

image

[root@zyx pub]# ftp 192.168.88.200

image

 

image

[root@zyx pub]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

[root@zyx pub]# ftp 192.168.88.200

 

image

image

[root@zyx pub]# cd /etc/pam.d
[root@zyx pam.d]# ll

image

[root@zyx pam.d]# cd /etc/vsftpd/            
[root@zyx vsftpd]# ll

image

[root@zyx vsftpd]# vim ftpusers

image

[root@zyx vsftpd]# ftp 192.168.88.200

image

[root@zyx vsftpd]# vim user_list

image

image

image

[root@zyx vsftpd]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

[root@zyx vsftpd]# ftp 192.168.88.200

image

image

[root@zyx vsftpd]# vim /etc/hosts.allow

image

[root@zyx vsftpd]# vim /etc/hosts.deny

image

[root@zyx vsftpd]# cat /etc/hosts.allow /etc/hosts.deny

image

image

image

安全性

安装抓包工具

[root@zyx Server]# ll wireshark-*

image

image

image

[root@zyx Server]# tshark -ni eth0 -R"tcp.dstport eq 21"

image

image

image

image

ftps  ftp+ssl

[root@zyx ~]# vim /etc/vsftpd/vsftpd.conf

image

image

image

 

image

[root@zyx CA]# mkdir crl certs newcerts
[root@zyx CA]# touch index.txt serial

[root@zyx CA]# echo "01" >serial

[root@zyx CA]# openssl genrsa 1024 >private/cakey.pem

image

[root@zyx CA]# chmod 600 private/*
[root@zyx CA]# openssl req -new -key private/cakey.pem -x509 -out cacert.pem

image

[root@zyx CA]# mkdir /etc/vsftpd/certs

[root@zyx certs]# openssl genrsa 1024 >vsftpd.key

image

[root@zyx certs]# openssl req -new -key vsftpd.key -out vsftpd.csr

image

[root@zyx certs]# ll
total 8
-rw-r--r-- 1 root root 643 Sep 20 20:08 vsftpd.csr
-rw-r--r-- 1 root root 887 Sep 20 20:06 vsftpd.key

[root@zyx certs]# openssl ca -in vsftpd.csr -out vsftpd.cert

image

[root@zyx certs]# ll
total 12
-rw-r--r-- 1 root root 3075 Sep 20 22:29 vsftpd.cert
-rw-r--r-- 1 root root  643 Sep 20 22:29 vsftpd.csr
-rw-r--r-- 1 root root  887 Sep 20 22:28 vsftpd.key

 

[root@zyx ~]# vim /etc/vsftpd/vsftpd.conf

image

[root@zyx certs]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]