SFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器 软件,它的全称是Very Secure FTP 从此名称可以看出来,编制者的初衷是代码的安全。下边介绍一下,vsftp的安装步骤。
1.查看linux系统版本和内核信息
1
2
3
4
5
6
[iyunv@vmware1 ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
[iyunv@vmware1 ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
2.关闭防火墙和selinux。
1
2
3
[iyunv@vmware1 ~]# /etc/init.d/iptables stop
[iyunv@vmware1 ~]# chkconfig iptables off
[iyunv@vmware1 ~]# setenforce 0
3.安装vsftp软件包。
1
[iyunv@vmware1 ~]# yum install -y vsftpd
先备份vsftpd的默认配置文件;
1
2
[iyunv@vmware1 ~]# cd /etc/vsftpd/
[iyunv@vmware1 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
[iyunv@vmware1 vsftpd]# 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
[iyunv@vmware1 vsftpd]# mkdir /data/taokey -p
创建用户taokey.
[iyunv@vmware1 vsftpd]# useradd taokey
[iyunv@vmware1 vsftpd]# passwd taokey 密码:123.com
更改用户 taokey 的密码 。
新的 密码:
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
给taokey目录,设置成
[iyunv@vmware1 vsftpd]# chown -R taokey.taokey /data/taokey
[iyunv@vmware1 vsftpd]# ll /data/
总用量 4
drwxr-xr-x 2 taokey taokey 4096 1月 16 14:54 taokey
7.安装db4数据包,一会生成数据库文件时候用,安装ftp客户端。
1
2
[iyunv@vmware1 ~]# yum install -y db4*
[iyunv@vmware1 vsftpd]# yum install -y ftp
8.创建一个匿名账号.
1
2
3
4
5
6
7
8
9
[iyunv@vmware1 ~]# cd /etc/vsftpd
[iyunv@vmware1 vsftpd]# echo "taokey" >vftpuser.txt
[iyunv@vmware1 vsftpd]# echo "123.com" >>vftpuser.txt
[iyunv@vmware1 vsftpd]# cat vftpuser.txt
taokey
123.com
[iyunv@vmware1 vsftpd]# db_load -T -t hash -f vftpuser.txt vftpuser.db
[iyunv@vmware1 vsftpd]# 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
[iyunv@vmware1 vsftpd]# 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
[iyunv@vmware1 ~]# cd /etc/vsftpd/
[iyunv@vmware1 vsftpd]# mkdir vsftpuser
[iyunv@vmware1 vsftpd]# cd vsftpuser/
[iyunv@vmware1 vsftpuser]# touch taokey
[iyunv@vmware1 vsftpuser]# 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
[iyunv@vmware1 ~]# service vsftpd restart
关闭 vsftpd: [确定]
为 vsftpd 启动 vsftpd: [确定]
[iyunv@vmware1 ~]# 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
[iyunv@vmware1 ~]# 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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com