linux安装vsftpd

article/2025/8/25 16:08:54

linux安装vsftpd

安装vsftpd作为附件上传和下载服务


文章目录

  • linux安装vsftpd
  • 一、vsftpd是什么?
  • 二、使用步骤
    • 1.安装
    • 2.配置
    • 3.可能出现的问题
      • 第一种情况:selinux的ftp设置
      • 第二种情况:可能是防火墙的原因
      • 第三种情况:pam.d设置问题
    • 4.建议
  • 总结


一、vsftpd是什么?

vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux, BSD, Solaris, HP-UX 以及 IRIX 上面。它支持很多其他的 FTP 服务器不支持的特征。

二、使用步骤

1.安装

检查服务器是否已经安装FTP
rpm -qa | grep vsftpd
如果已存在则先卸载
yum remove vsftpd
我这里是新的服务器	所以就直接安装vsftpd 
yum install vsftpd -y

在这里插入图片描述

安装成功

在这里插入图片描述

2.配置

设置用户的信息和权限
解释一下这句命令
添加一个用户名为qingdgj的用户属于root组 
登录的时候默认进入/home/ftp目录
不能通过shell登录只能 通过ftp登录
useradd -g root -d /home/ftp-s /sbin/nologin qingdgj
给这个用户设置密码
passwd qingdgj
输入的密码是不会在页面上显示的

在这里插入图片描述

设置文件夹权限(注意用户名)

在这里插入图片描述

修改配置文件
vim /etc/vsftpd/vsftpd.conf
这里给出一份说明
#配置信息  需要修改服务器ip和端口号
#是否允许匿名用户访问
anonymous_enable=NO
#是否允许本地用户登录FTP
local_enable=YES
#是否允许登陆用户有写权限,默认值为 YES。
write_enable=YES
#匿名用户上传文件的umask值
local_umask=022
dirmessage_enable=YES
#是否启用上传/下载日志记录。如果启用,则上传与下载的信息将被完整纪录在 xferlog_file 所定义的档案中。
xferlog_enable=YES
#端口监听
port_enable=YES
#指定 FTP使用 20端口进行数据传输,默认值为 YES。
connect_from_port_20=YES
#若启用此选项,所有的 FTP请求和响应都会被记录到日志中,默认日志文件在/var/log/vsftpd.log。
#启用此选项时,xferlog_std_format不能被激活。这个选项有助于调试。默认值为 NO。
xferlog_std_format=YES
#设置是否启用 ASCII 模式上传数据。默认值为 NO。
ascii_upload_enable=YES
#设置是否启用 ASCII 模式下载数据。默认值为 NO。
ascii_download_enable=YES
ls_recurse_enable=YES
#设置 FTP服务器建立连接所监听的端口,默认值为 21。
listen=YES
#设置 FTP服务器建立连接所监听的端口,默认值为 21。
listen_port=xxx端口号
pam_service_name=vsftpd
##设置用户列表为“允许”还是“禁止”操作  当在/etc/vsftpd.conf中设置了userlist_deny=NO时,仅仅允许/etc/vsftpd.user_list中指定的用 户访问FTP服务器。
userlist_deny=NO
#设置用户列表为“允许”还是“禁止”操作
userlist_enable=YES
##设置用户列表
userlist_file=/etc/vsftpd/user_list
#被动模式开关
pasv_enable=YES
#被动模式最小端口
pasv_min_port=xxx端口号
#被动模式最大端口
pasv_max_port=xxx端口号
#本地在公网ip
pasv_address=服务器ip
pasv_addr_resolve=YES
#匿名用户的最大传输速率(字节/秒),0为不限制
anon_max_rate=512000
#本地用户最大传输速率(字节/秒),0为不限制
local_max_rate=512000
#允许ip变化  防止 425 Security: Bad IP connecting.
pasv_promiscuous=YES

在这里插入图片描述

配置修改好之后启动ftp服务
systemctl start vsftpd.service
查看ftp服务状态

在这里插入图片描述

用ftp工具连接一下  可以成功连接 上传和下载文件

在这里插入图片描述
在这里插入图片描述

3.可能出现的问题

-------------------------------------------------------------
命令:	USER qingdgj
响应:	331 Please specify the password.
命令:	PASS ***********
响应:	530 Login incorrect.
错误:	严重错误: 无法连接到服务器
-------------------------------------------------------------

第一种情况:selinux的ftp设置

这里centos6和centos7是不一样的 
如果selinux是开启的 则要设置
#查看selinux中ftp的相关配置
sestatus -b | grep ftp
如果显示 ftp_home_dir  off 则需要打开
#selinux设置(这里给出centos7设置方法)
sudo setsebool -P tftp_home_dir 1
如果不想设置也可以关闭selinux

第二种情况:可能是防火墙的原因

可以选择关闭防火墙 或者开启对应的端口
# ftp被动模式 端口
firewall-cmd --zone=public --add-port=起始端口-结束端口/tcp --permanent
# ftp登录端口
firewall-cmd --zone=public --add-port=xxx端口/tcp --permanent
# 购买的云服务器
如果是阿里云、腾讯云的服务器 需要在安全组里面开启对应的规则

第三种情况:pam.d设置问题

在前面的ftp配置的时候设置了 pam_service_name=vsftpd 这个属性
vim /etc/pam.d/vsftpd
我们只要把 pam_shells.so 改成pam_nologin.so即可

在这里插入图片描述

4.建议

建议在修改原来的配置文件时都对原来的配置文件进行一下备份,以防操作不当引起的问题。
这里提供一份原版配置(版本3.0.2)
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
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.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#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
#
# Activate logging of uploads/downloads.
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
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# 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=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

总结

	安装ftp服务容易遇到一些小问题,上面列举的是比较常见的几种情况,
希望能对大家有所帮助。感谢你的阅读。

http://chatgpt.dhexx.cn/article/17jdtOA7.shtml

相关文章

1、vsftpd的简介

1、vsftpd的简介 vsftpd是“very secure TTP daemon”的缩写,是一个完全免费的、开放源代码的ftp服务器软件 2、特点 vsftpd是一款在Linux发行版中最受推崇的ftp服务器程序,小巧轻快,安全易用,支持虚拟用户,支持带宽…

vsftpd基本使用

ftp: 文件传输协议 两类连接: 命令连接:传输命令 数据连接:传输数据 两种模式: 主动模式:PORT 20/tcp连接客户端的命令连接使用的端口向后的第一个可用端口 被动模式:PASV 打开一个随机端口,并…

vsftpd部署流程和常见问题详解

vsftpd部署流程和常见问题详解 ⭐️ 网上关于在云服务器里配置vsftpd的文章鱼龙混杂,没有一篇是可以彻底解决问题的,有些问题虽简单,但也让初学者感到困惑。本文详细说明vsftpd的部署流程和一些常见问题的解决方法,详述用户创建过…

Linux vsFTPd服务详解——vsFTPd基础知识

今天继续给大家介绍Linux运维相关内容,本文主要内容是Linux的vsFTPd服务。 一、vsFTPd服务简介与安装 FTP服务,即File Transfer Protocol、文件传输服务,用于在互联网上提供文件存储和访问服务。有关FTP的原理请参见以下文章:FT…

vsftpd的安装和使用

目录 1、vsftpd的简介... 2 2、特点... 2 3、安装... 2 4、创建虚拟用户... 2 5、vsftpd服务器的配置... 4 6、vsftpd配置文件说明... 7 7、防火墙的配置... 8 8、vsftpd的验证... 9 9、vsftpd的常用命令... 10 10、反复需要验证ftp身份问题解决... 10 1、vsftpd的简…

Number、parseInt和parseFloat的区别

1、Number() 可以把任何类型的数据转换为数值或NaN(not a number),parseInt()和parseFloat()只能把字符串或数值转换为数值; 2、Number()和parseFloat()会有效解析浮点数(如"324.11abc"转为324.11),而parse…

parseFloat()函数的使用

定义: parseFloat() 函数可解析一个字符串,并返回一个浮点数。该函数指定字符串中的首个字符是否是数字。如果是,则对字符串进行解析,直到到达数字的末端为止,然后以数字返回该数字,而不是作为字符串。 语…

Float.parseFloat()的作用

parseFloat()方法用于返回与给定String表示形式相对应的float值 类型转换: string转float

java float.parsefloat_java.lang.Float.parseFloat()方法实例

全屏 java.lang.Float.parseFloat()方法返回一个为指定String表示新的浮点初始化值,由Float类的valueOf方法执行的值。 声明 以下是java.lang.Float.parseFloat()方法的声明public static float parseFloat(String s) throws NumberFormatException 参数s -- 这是要…

从ES规范和引擎细谈 js 中 parseInt 和 parseFloat 的执行机制

从ES规范和引擎细谈 js 中 parseInt 和 parseFloat 的执行机制 parseInt()和parseFloat()这两个常用 API 其实还是有很多“坑”的,以此文统一梳理一下。(本文比较适合常与数字打交道的 jser 或对这两 API 运作感兴趣的同学) (git…

python实现简单的聊天小程序

概要 这是一个使用python实现一个简单的聊天室的功能,里面包含群聊,私聊两种聊天方式.实现的方式是使用套接字编程的一个使用TCP协议 c/s结构的聊天室 实现思路 x01 服务端的建立 首先,在服务端,使用socket进行消息的接受,每接受一个socket的请求,就开启一个新的线程来管理…

微信小程序调出选择好友聊天窗口

微信小程序分享好友 点击分享,弹出层选择“分享给微信好友”,点击‘“分享给微信好友”,直接调出选择好友聊天窗口。 如图: 微信小程序API:onShareAppMessage 定义 onShareAppMessage 函数,设置该页面的…

小程序mqtt实现聊天功能

mqtt是什么? MQTT是一个轻量级传输协议,它被设计用于轻量级的发布/订阅式消息传输,MQTT协议针对低带宽网络,低计算能力的设备,做了特殊的优化。是一种简单、稳定、开放、轻量级易于实现的消息协议,在物联网…

微信小程序接入腾讯IM即时通讯,实现在线聊天

最近在帮朋友写一个二手交易平台,买卖双方在线沟通的功能(类似于某鱼) 先上传做完的效果图,后续再更新源码,目前实现了消息列表显示未读数量,显示最后一条信息内容,收到信息后刷新列表。聊天页面 不要吐槽…

应用实战|微信小程序开发示例--多人聊天互动空间

“超能力”数据库~拿来即用,应用开发人员再也不用为撰写API而发愁。MemFire Cloud 为开发者提供了简单易用的云数据库(表编辑器、自动生成API、SQL编辑器、备份恢复、托管运维),很大地降低开发者的使用门槛。 本示例是…

微信小程序实现websocket及单人聊天功能

一、什么是websocket: WebSocket是HTML5下一种新的协议(websocket协议本质上是一个基于tcp的协议)它实现了浏览器与服务器全双工通信,能更好的节省服务器资源和带宽并达到实时通讯的目的Websocket是一个持久化的协议 二、websoc…

uni-app+websocket实现语音聊天小程序

uni-appwebsocket 开发语音聊天咨询小程序

微信小程序中百分百实现聊天界面

众所周知,全网来看,微信的聊天界面看着就是舒服,那能否在微信小程序中实现该功能,同时可以实现输入文本和语音功能,而且在输入文本时,键盘可以弹起。话不多说,上界面看看。 wxml实现如下: <view> <scroll-view scroll-y scroll-into-view={{toView}} style=h…

图灵聊天机器人小程序

历时半年整理出了十多万字的学习笔记&#xff0c;目前依旧在更新 欢迎点赞和支持&#xff5e;&#x1f973;&#x1f973;&#x1f973; 博客 项目描述&#xff1a; 根据图灵API向聊天机器人发送聊天信息&#xff0c;并渲染返回的数据。具有清空聊天记录的按钮。本来是想上线…

微信小程序-模仿绘制聊天界面

参考文章 1、小程序模仿微信聊天界面 2、微信小程序实现仿微信聊天界面(各种细节处理) 3、微信小程序之页面中关于聊天框三角形的制作和使用 4、仿微信聊天记录时间显示 5、微信小程序-同时获取麦克风、相机权限、获取多个权限 6、【uni-app】模仿微信实现简易发送/取发语音功…