43tw2e2 发表于 2015-1-20 08:40:43

centos6.5_64位系统安装VSFTP

SFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP 从此名称可以看出来,编制者的初衷是代码的安全。下边介绍一下,vsftp的安装步骤。
1.查看linux系统版本和内核信息

1
2
3
4
5
6
# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m




2.关闭防火墙和selinux。


1
2
3
# /etc/init.d/iptables stop
# chkconfig iptables off
# setenforce 0




3.安装vsftp软件包。

1
# yum install -y vsftpd




先备份vsftpd的默认配置文件;

1
2
# cd /etc/vsftpd/
# cp vsftpd.conf vsftpd.conf.bak




4.清空vsftpd.cong默认的内容。

1
root@vmware1 vsftpd]# >vsftpd.conf




5.修改后的内容为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# cat vsftpd.conf
anonymous_enable=NO                  #不允许匿名用户登陆
local_enable=YES                     #vsftpd所在系统的用户可以登录vsftpd
write_enable=YES                     #允许使用任何可以修改文件系统的FTP的指令
local_umask=002                        #匿名用户新增文件的umask数值
anon_upload_enable=NO                  #匿名用户不可以上传文件
anon_mkdir_write_enable=NO             #匿名用户不可以修改文件
xferlog_enable=YES                     #启用一个日志文件,用于详细记录上传和下载。               
use_localtime=YES                      #使用本地时间而不是GMT
vsftpd_log_file=/var/log/vsftpd.log    #vsftpd日志存放位置
dual_log_enable=YES                  #用户登陆日志
connect_from_port_20=YES               #开启20端口   
xferlog_file=/var/log/xferlog          #记录上传下载文件的日志
xferlog_std_format=YES               #记录日志使用标准格式
idle_session_timeout=600               #登陆之后超时时间60秒,登陆之后,一分钟不操作,就会断开连接。
chroot_local_user=YES                  #用于指定用户列表文件中的用户,是否允许切换到上级目录   
listen=YES                           #开启监听
pam_service_name=vsftpd.vu             #验证文件的名字
userlist_enable=YES                  #允许由userlist_file指定文件中的用户登录FTP服务器                  
tcp_wrappers=YES                     #支持tcp_wrappers,限制访问(/etc/hosts.allow,/etc/hosts.deny)
guest_enable=YES                     #起用虚拟用户
guest_username=taokey                  #虚拟用户名
user_config_dir=/etc/vsftpd/vsftpuser#虚拟用户配置文件路径
pasv_min_port=35000
pasv_max_port=45000
pasv_enable=YES
pasv_promiscuous=YES
anon_other_write_enable=YES




6.创建ftp访问的目录,创建本地ftp用户,设置密码。

1
2
3
4
5
6
7
8
9
10
11
12
13
# mkdir /data/taokey -p
创建用户taokey.
# useradd taokey
# passwd taokey   密码:123.com
更改用户 taokey 的密码 。
新的 密码:
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
给taokey目录,设置成
# chown -R taokey.taokey /data/taokey
# ll /data/
总用量 4
drwxr-xr-x 2 taokey taokey 4096 1月16 14:54 taokey




7.安装db4数据包,一会生成数据库文件时候用,安装ftp客户端。

1
2
# yum install -y db4*
# yum install -y ftp




8.创建一个匿名账号.

1
2
3
4
5
6
7
8
9
# cd /etc/vsftpd
# echo "taokey" >vftpuser.txt
# echo "123.com" >>vftpuser.txt      
# cat vftpuser.txt
taokey
123.com
# db_load -T -t hash -f vftpuser.txt vftpuser.db            
# ll vftpuser.db
-rw-r--r-- 1 root root 12288 1月16 15:14 vftpuser.db




9.添加验证信息,在/etc/pam.d目录下,新创建一个vsftpd.vu文件,写入内容如下。

1
2
3
# cat /etc/pam.d/vsftpd.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vftpuser
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vftpuser




10.创建虚拟用户的配置文件。

1
2
3
4
5
6
7
8
9
10
11
12
# cd /etc/vsftpd/
# mkdir vsftpuser
# cd vsftpuser/
# touch taokey
# cat taokey
local_root=/data/taokey
write_enable=YES
anon_mkdir_write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_umask=022
anon_other_write_enable=YES




11.重启vsftpd,然后查看端口是否开启。

1
2
3
4
5
# service vsftpd restart   
关闭 vsftpd:                                              [确定]
为 vsftpd 启动 vsftpd:                                    [确定]
# netstat -anpt | grep vsftpd
tcp      0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      2191/vsftpd




12.在本地ftp服务器登陆测试。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (127.0.0.1:root): taokey
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
227 Entering Passive Mode (127,0,0,1,149,179).
150 Here comes the directory listing.
226 Directory send OK.
ftp> mkdir hello
257 "/hello" created
ftp> dir
227 Entering Passive Mode (127,0,0,1,141,105).
150 Here comes the directory listing.
drwxr-xr-x    2 500      500          4096 Jan 16 15:27 hello
226 Directory send OK.




到此为止,VSFTP搭建完成,实验结束。

页: [1]
查看完整版本: centos6.5_64位系统安装VSFTP