vsftp配置使用
- vsftp简介:
VSFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP 从此名称可以看出来,编制者的初衷是代码的安全。
安全性是编写VSFTP的初衷,除了这与生俱来的安全特性以外,高速与高稳定性也是VSFTP的两个重要特点。
在速度方面,使用ASCII代码的模式下载数据时,VSFTP的速度是Wu-FTP的两倍,如果Linux主机使用2.4.*的内核,在千兆以太网上的下载速度可达86MB/S。
在稳定方面,VSFTP就更加的出色,VSFTP在单机(非集群)上支持4000个以上的并发用户同时连接,根据Red Hat的Ftp服务器(ftp.redhat.com)的数据,VSFTP服务器可以支持15000个并发用户。
- vsftp的安装配置:
安装vsftp需要用到root权限,尽可能的在root用户下进行安装
切换root权限 sudo su -
1. 检查vsftp是否安装
rpm -qa vsftp [无结果表明没有安装]
2. 安装vsftp
yum install -y vsftpd
[root@m01 ~]# yum install -y vsftpd
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be installed
--> Finished Dependency Resolution
...
Installed:
vsftpd.x86_64 0:2.2.2-24.el6
Complete! --- 安装完成
3. 创建一个日志文件来记录ftp上传下载的记录
touch /var/log/vsftpd.log
检查vsftp开机启动选项[yum安装后会自动添加开机启动,但是并没有配置,如果需要开机启动则进行配置]
查看开机启动: chkconfig --list|grep vsftpd
[root@m01 ~]# chkconfig --list|grep vsftpd
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
设置35级别开机启动:
[root@m01 ~]# chkconfig --level 35 vsftpd on
[root@m01 ~]# chkconfig --list | grep vsftpd
vsftpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
3.服务的启动关闭
方式1:
vsftpd安装完成后会默认添加到系统服务和init中 所以可以使用以下方法查看和启动服务
/etc/init.d/vsftpd status | [/etc/init.d/vsftpd {start|stop|restart|try-restart|force-reload|status}] 常用 start|stop|restart 这3个
方式2:
[root@m01 ~]# service vsftpd status [start|stop|restart|try-restart|force-reload|status]
vsftpd is stopped
一般常用 start|stop|restart
start 启动
stop 停止
restart 重新启动
4.vsftp配置权限
了解配置权限之前需要先了解配置文件,如何查看配置文件?
rpm -ql vsftpd 命令可以看到软件安装路径,以及配置文件
重要的配置文件:
/etc/vsftpd/ftpusers ---禁止登录用户的黑名单列表
/etc/vsftpd/user_list ---允许登录的用户白名单列表
/etc/vsftpd/vsftpd.conf ---vftp的重要配置信息
问题:
这里看到两个user,那么ftpusers和user_list两个文件各自的用途是什么?有何关系?
ftpusers 这是一个黑名单用户列表,也就是禁止登录的 比如可以设置 root禁止登录来保证ftp安全
来看下这个配置文件让你更加清晰你在做什么:
[root@m01 ~]# cat /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
这些都是被禁止登录的用户
5. vsftpd.conf 配置文件
这里东西较多,理解就好
先来查看配置并解释:
vim /etc/vsftpd/vsftpd.conf
==========================vsftpd.conf===========================================
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
====================================================================================
看起来很多,如果解释完过滤出需要配置的 你会发现也没多少
[root@m01 ~]# grep -v "#" /etc/vsftpd/vsftpd.conf 【过滤出的都是默认配置】
anonymous_enable=YES ----匿名用户 yes 为允许 no为拒绝 //不允许匿名用户访问,默认是允许
local_enable=YES ----本地模式是否开启 yes 开机 no 关闭 这里默认即可 不需要修改 就是验证本地用户用的
write_enable=YES ----是否开启写入权限 默认yes
local_umask=022 ----umask值 这是设置权限的掩码,默认即可
dirmessage_enable=YES ----这是登录是否显示进入目录标语 默认即可
xferlog_enable=YES ----日志功能 这个默认开启 日志地址/var/log/vsftpd.log
connect_from_port_20=YES ----默认连接端口 不用改
xferlog_std_format=YES ----用于设置vsftpd的服务日志保存路径,不用改
listen=YES
pam_service_name=vsftpd ----设定pam服务下vsftpdd的验证配置文件名,不用改
userlist_enable=YES ----拒绝登录用户名单,不用改
TCP_wrappers=YES ----限制主机对VSFTP服务器的访问,不用改(通过/etc/hosts.deny和/etc/hosts.allow这两个文件来配置)
配置ftp账户:
1、修改/etc/vsftpd/vsftpd.conf,将底下三行
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
改为
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
2、增加用户ftpuser,指向目录/home/wwwroot/ftpuser,禁止登录SSH权限。
useradd -d /home/wwwroot/ftpuser -g ftp -s /sbin/nologin ftpuser
3、设置用户口令
passwd ftpuser
4、编辑文件chroot_list(内容为ftp用户名,每个用户占一行):
vi /etc/vsftpd/chroot_list
启用pasv模式
pasv_enable=YES #启用被动模式
pasv_min_port=10000 #被动模式使用端口范围
pasv_max_port=10010 #被动模式使用端口范围
第五步、针对第四步开启防火墙端口,如果没有启用pasv模式就可以不用管
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10000:10010 -j ACCEPT
在以上工序完成后,连接ftp时出现了个错误
500 OOPS: vsftpd: cannot locate user specified in 'ftp_username':ftp
经过网络搜索,得到下面的解决办法
在/etc/vsftpd.conf中添加一行ftp_username=nobody就搞定
ftp测试连接
在连接之前要确认是否安装了ftp命令
rpm -qa ftp
没有安装就直接安装
yum install -y ftp
安装完成测试连接ftp服务器
[root@db01 ~]# ftp 10.0.0.61
Connected to 10.0.0.61 (10.0.0.61).
220 (vsFTPd 2.2.2)
Name (10.0.0.61:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
# 方法一
# 创建用户 ftpuser 指定 `/home/vsftpd` 目录
useradd -g root -M -d /home/vsftpd -s /sbin/nologin ftpuser
# 设置用户 ftpuser 的密码
passwd ftpuser
# 把 /home/vsftpd 的所有权给ftpuser.root
mkdir /home/vsftpd -p
chown -R ftpuser.root /home/vsftpd
# 方法二
useradd ftpuser -d /home/vsftpd -s /bin/false
chown ftpuser:ftpuser /home/vsftpd -R
# 如果虚拟用户的宿主用户为www,需要这样设置
# www目录是你应用的目录
chown www:www /home/www -R
ftp上传下载操作命令:
bin 二进制传输模式
prompt 上传提示开关 多文件上传建议改为off
mput 上传
mget 下载 上传下载均可以使用* 进行通配
lcd 切换本地目录
cd 切换ftp目录
登录演示:
ftp 10.0.0.61
Connected to 10.0.0.61 (10.0.0.61).
220 (vsFTPd 2.2.2)
Name (10.0.0.61:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
ftp>
ftp> ls
227 Entering Passive Mode (10,0,0,61,156,196).
150 Here comes the directory listing.
226 Directory send OK.
vsftp配置使用的更多相关文章
- Vsftp的PASV mode(被动模式传送)和Port模式及 Linux下VsFTP配置全方案
什么叫做PASV mode(被动模式传送)?他是如何工作的? FTP的连接一般是有两个连接的,一个是客户程和服务器传输命令的,另一个是数据传送的连接.FTP服务程序一般会支持两种不同的模式,一种是Po ...
- vsftp配置日志及其启用本地时间
vsftp配置日志及其启用本地时间 1. 启用vsftp日志 xferlog_enable=YES xferlog_std_format=YES xferlog_file=/var/log/xferl ...
- Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程
Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程 1.先切换到root用户 sudo su 2.更新软件源 apt update apt-get upgrade 3. ...
- vsftp 配置
安装和基本配置网上很多文章,但他们的最终效果不是我想要的: 我想要的是,ftp上传的文件用户可以通过apache的http服务访问,也就是ftp上传的文件可以通过浏览器访问,并且可以通过ftp客户端修 ...
- centos7.0 vsftp配置
7.0版本 1.安装 yum -y install vsftpd 2.配置 vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO //设定不允许匿名访问 loc ...
- VSFTP 配置虚拟用户
虚拟用户的特点是只能访问服务器为其提供的FTP服务,而不能访问系统的其它资源.所以,如果想让用户对FTP服务器站内具有写权限,但又不允许访问系统其它资源,可以使用虚拟用户来提高系统的安全性. 在VSF ...
- vsftp配置
网上很多,但我还是想再整理一份属于自己的 1.vsftp简介 vsftp提供三种登陆方式:.匿名登录 .本地用户登录 .虚拟用户登录 vsftpd的特点:.较高的安全性需求 .带宽的限制 .创建支持虚 ...
- LINUX VSFTP配置及安装
------------------转载:亲身实践,确实好用(http://www.cnblogs.com/jack-Star/p/4089547.html) 1.VSFTP简介 VSFTP是一个基于 ...
- linux vsftp配置
1.rpm -q ftp 查看是否安装ftp服务器 2.yum install vsftp 安装ftp服务器 3.修改配置文件/etc/vsftpd 下面的 ftpusers和user_list,这两 ...
- Linux vsftp配置本地用户
主要讲的是配置本地用户, ftp现在用的也少了,一般都用ssh和svn 1. 安装ftp yum -y install vsftpd 2. 配置 /etc/vsftpd/vsftpd.conf # ...
随机推荐
- CentOS 利用pam控制ssh用户的登录及SSH安全配置
CentOS 利用pam控制ssh用户的登录 有关pam的使用,请找相关的文档.下面只说两个简单的例子. 首先在/etc/pam.d/sshd加入一句: account required ...
- Avalonia 中的样式和控件主题
在 Avalonia 中,样式是定义控件外观的一种方式,而控件主题则是一组样式和资源,用于定义应用程序的整体外观和感觉.本文将深入探讨这些概念,并提供示例代码以帮助您更好地理解它们. 样式是什么? 样 ...
- 重新整理 mysql 基础篇————— 索引模型[五]
前言 简单整理一下索引模型. 正文 对我们开发人员来说,索引感觉非常的重要. 因为索引好用,但是不能多建,因为这影响插入,不能少建,因为这影响读取. 有些为了能够多建索引,通过从多个从库中读取数据,再 ...
- 力扣25(java&python)-K 个一组翻转链表(困难)
题目: 给你链表的头节点 head ,每 k 个节点一组进行翻转,请你返回修改后的链表. k 是一个正整数,它的值小于或等于链表的长度.如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺 ...
- 力扣20(java)-有效的括号(简单)
题目: 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效. 有效字符串需满足: 左括号必须用相同类型的右括号闭合.左括号必须以正确的顺序闭合.每个右括 ...
- 力扣233(java)-数字1的个数(困难)
题目: 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数. 示例 1: 输入:n = 13输出:6示例 2: 输入:n = 0输出:0 提示: 0 <= n <= ...
- ARMS实践|日志在可观测场景下的应用
简介: 在实际生产中,通过灵活组合文内几种使用方式,运维团队可以很好地排除日常观测.故障定位过程中的干扰因素,更快的定界甚至定位问题根因. 作者:陈陈 日志在可观测场景下的应用 随着 IT 架 ...
- 如何可视化编写和编排你的 K8s 任务
简介: 通过任务调度 SchedulerX 来调度你的 K8s 任务,能够降低学习成本,加快开发效率,让你的任务失败可报警,出问题可排查,打造云原生可观测体系下的可视化 K8s 任务. 作者:学仁 ...
- “让专业的人做专业的事”,畅捷通与阿里云的云原生故事 | 云原生 Talk
简介: 如何借助阿里云强大的 IaaS 和 PaaS 能力去构建新一代的 SaaS 企业应用,从而给客户提供更好.更强的服务,这是畅捷通一直在思考和实践的方向.最终,畅捷通选定阿里云企业级分布式应用服 ...
- 深度解析|基于 eBPF 的 Kubernetes 一站式可观测性系统
简介:阿里云 Kubernetes 可观测性是一套针对 Kubernetes 集群开发的一站式可观测性产品.基于 Kubernetes 集群下的指标.应用链路.日志和事件,阿里云 Kubernete ...