一、问题的由来

对自己在局域网搭建的centos5 vsftpd服务器抓包,发现用户名和密码都是明文的。

搭建支持ssl的vsftpd服务器

 二、安装ssl

让vsftpd支持SSL,必须让OPENSSL≥0.9.6版本,还有就是本身vsftpd版本是否支持。查询vsftpd软件是否支持SSL:

[[email protected] vsftpd]# ldd /usr/sbin/vsftpd |grep libssl
libssl.so.6 => /lib/libssl.so.6 (0xf7f27000)   

说明此版本支持。

如没有输出libssl.so.6 => /lib/libssl.so.6 (0xf7f27000)类似文本,说明此vsftpd版本不支持SSL。

[[email protected]  ~]#openssl req -x509 -nodes -days 365 -newkey rsa:1024 /-keyout  /etc/vsftpd/vsftpd.pem /-out /etc/vsftpd/vsftpd.pem  #生成vsftpd.pem 证书
Generating a 1024 bit RSA private key
..++++++
....................................++++++
writing new private key to 'vsftpd.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:cn
State or Province Name (full name) [Berkshire]: shanghai
Locality Name (eg, city) [Newbury]:shanghai
Organization Name (eg, company) [My Company Ltd]:ys   

#根据提示填写一些信息
Organizational Unit Name (eg, section) []:ys
Common Name (eg, your name or your server's hostname) []:viong
Email Address []:[email protected]

[[email protected] ~]# ll /etc/vsftpd/  #查看是否生成vsftpd.pem文件
-rw-r--r-- 1 root root  197 12-25 19:57 chroot_list
-rw--------1 root root 125 2007-12-13 ftpusers
-rw------- 1 root root  361 2007-12-13 user_list
-rw------- 1 root root 4396 12-25 19:19 vsftpd.conf
-rwxr--r-- 1 root root  338 2007-12-13 vsftpd_conf_migrate.sh
-rw-r--r-- 1 root root 2168 01-08 01:53 vsftpd.pem  #生成vsftpd.pem成功

[[email protected] ~]# vi /etc/vsftpd/vsftpd.conf  #编辑主配置文件,添加以下参数
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/vsftpd/vsftpd.pem

重启vsftpd服务:service vsftpd restart。

三、客户端如何访问

由于IE和firefox均不支持ssl访问,因此要访问支持ssl的vsftpd服务器,还必须用支持ssl的客户端工具。下图就是用IE打开ssl的vsftpd服务器时弹出的错误提示:

搭建支持ssl的vsftpd服务器

在linux有lftp,win平台下flashfXP。下面就是flashfXP的快速连接设置界面。

搭建支持ssl的vsftpd服务器 搭建支持ssl的vsftpd服务器

四、iptables设置

搭建支持ssl的vsftpd服务器