Ubuntu16.04 ftp服务器安装+配置

简介: Ubuntu16.04 ftp服务器安装+配置

最近在配置阿里云服务器,需要把本地的代码和资料上传到服务器,运行测试。

于是就需要自己搭建一个FTP服务。

ftp服务器安装与配置


1. ftp服务端的安装

如果之前配置过ftp服务器的还是之后配置的服务器,无法启动服务,那么基本是配置出现了错误,那么可先完全卸载后再进行安装。如果无法定位多半是镜像源的问题,请更换阿里源。

sudo apt-get update sudo apt-get install vsftpdvsftpd --version     //检测是否安装

2.ftp服务端的配置

 vim /etc/vsftpd.conf    //编辑配置文件

修改vsftpd.conf文件如下:

listen=NO                 //是否开启监听ipv4和ipv6数据   
   listen_ipv6=YES          //是否开启监听ipv6数据
 # Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO      //是否允许匿名登陆,无需密码
 # 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       //设置本地用户默认要减免的权限
 # Activate directory messages - messages given to remote users when they# go into a certain
 directory.dirmessage_enable=YES   //目录消息,能够给远程登陆的用户发送目录
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=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    //确认连接传输的端口号为20 
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log    //日志文件存放位置
#
# 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 fully customise the login banner string:ftpd_banner=Welcome to FTP service.  //在使用shell时登陆那么会发送欢迎语  
# 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        //白名单路径,若无这个文件需要自己创建
 # This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.# pam_service_name=vsftpdpam_service_name=ftp            //此处ubuntu的系统需要改为ftp
 # This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pemrsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.keyssl_enable=NO               
#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.utf8_filesystem=YES       //编码统一为utf8编码,可以识别中文,防止乱码
 3. vftpd配置完成

添加设置ftpuser用户和访问目录


 1. 创建ftp用户组和用户
sudo groupadd ftpusers //创建ftpusers用户组
sudo useradd -m ftpuser_lxr//创建一个用户并且自动创建家目录为/home/ftpuser_lxr
(第二种方式:mkdir /home/ftpuser_lxr //先创建家目录sudo userad -d /home/ftpuser_lxr ftpuser_lxr //绑定这个家目录)
usermod -G ftpusers ftpuser_lxr //将这个新用户加入到ftpusers用户组中
sudo passwd ftpuser_lxr   //更改密码
mkdir /home/ftpuser_lxr/ftp  //为用户添加一个具有一定权限的文件夹
chmod 777 -R /home/ftpuser_lxr/ftp //新建一个pub目录用于存放文件,并且赋予全部权限
usermod -s /sbin/nologin username  //限制用户登录方式;限制用户username只能通过ftp登陆,而不能直接[登陆服务器](https://www.aliyun.com/minisite/goods?userCode=gy5l4yp9)
2.将该用户加入vsftpd.chroot_list白名单中
mkdir /etc/vsftpd.chroot_listvim vsftpd.chroot_list

该文件内容如下:

#白名单ftpuser_lxr
3.开启并重启vsftpd的服务

systemctl start vsftpd或者service vsftpd start 
systemctl restart vsftpd或者service vsftpd restart


测试

方法一:

打开浏览器,在地址栏输入:ftp://ip_addresss

方法二:

 在ubuntu中使用shell输入:ftp ip_address

方法三:

 在windows中在文件管理器地址栏输入:ftp://ip_addresss,该方式可以上传下载文件

方法四:

 在windows中使用cmd输入:ftp://ip_addresss //显示连接成功
目录
相关文章
|
15天前
|
弹性计算 Ubuntu Linux
阿里云服务器一键安装Docker社区版教程,基于系统运维管理OOS
阿里云服务器一键安装Docker社区版教程,基于系统运维管理OOS自动化部署。支持Ubuntu 22.04/20.04、CentOS 7.7-7.9及Alibaba Cloud Linux 3.2104 LTS。前提条件:ECS实例需运行中且有公网。步骤:选择Docker扩展并安装,验证成功通过命令`docker -v`查看版本号。
187 79
|
1月前
|
存储 人工智能 自然语言处理
ChatMCP:基于 MCP 协议开发的 AI 聊天客户端,支持多语言和自动化安装 MCP 服务器
ChatMCP 是一款基于模型上下文协议(MCP)的 AI 聊天客户端,支持多语言和自动化安装。它能够与多种大型语言模型(LLM)如 OpenAI、Claude 和 OLLama 等进行交互,具备自动化安装 MCP 服务器、SSE 传输支持、自动选择服务器、聊天记录管理等功能。
195 15
ChatMCP:基于 MCP 协议开发的 AI 聊天客户端,支持多语言和自动化安装 MCP 服务器
|
2月前
|
Ubuntu 网络协议 关系型数据库
超聚变服务器2288H V6使用 iBMC 安装 Ubuntu Server 24.04 LTS及后续系统配置
【11月更文挑战第15天】本文档详细介绍了如何使用iBMC在超聚变服务器2288H V6上安装Ubuntu Server 24.04 LTS,包括连接iBMC管理口、登录iBMC管理界面、配置RAID、安装系统以及后续系统配置等步骤。
304 4
|
2月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
93 4
|
3月前
|
监控 Java Linux
Linux系统之安装Ward服务器监控工具
【10月更文挑战第17天】Linux系统之安装Ward服务器监控工具
82 5
Linux系统之安装Ward服务器监控工具
|
3月前
|
人工智能 安全 大数据
ARM 服务器上安装 OpenEuler (欧拉)
openEuler 是华为于2019年开源的操作系统,支持多种处理器架构,包括X86和鲲鹏。截至2020年底,openEuler 拥有3万社区用户、2万多个拉取请求、2000多名贡献者和7032款软件。openEuler 提供高效、稳定、安全的系统,适用于数据库、大数据、云计算和人工智能等场景。本文介绍了在神州鲲泰 R522 服务器上安装 openEuler 的详细步骤,包括下载镜像、配置 RAID 和 BIOS 设置等。
400 0
ARM 服务器上安装 OpenEuler (欧拉)
|
3月前
|
弹性计算 应用服务中间件 网络安全
ECS服务器使用:SSL证书安装、配置和问题定位指南
本文简要介绍了SSL证书的生成与部署方法,包括使用OpenSSL生成自签名证书和从CA获取证书的步骤,以及在Apache和Nginx服务器上的配置方法。此外,还提供了测试证书是否生效的方法和常见问题的解决策略,帮助确保证书正确安装并解决调试过程中可能遇到的问题。
272 0
|
3月前
|
域名解析 安全 网络安全
阿里云服务器WordPress环境上安装SSL证书
阿里云服务器WordPress环境上安装SSL证书
|
3月前
|
安全 网络协议 网络安全
Windows Server 2003 FTP服务器搭建
Windows Server 2003 FTP服务器搭建
|
29天前
|
安全 编译器 Linux
深入解析与防范:基于缓冲区溢出的FTP服务器攻击及调用计算器示例
本文深入解析了利用缓冲区溢出漏洞对FTP服务器进行远程攻击的技术,通过分析FreeFlow FTP 1.75版本的漏洞,展示了如何通过构造过长的用户名触发缓冲区溢出并调用计算器(`calc.exe`)。文章详细介绍了攻击原理、关键代码组件及其实现步骤,并提出了有效的防范措施,如输入验证、编译器保护和安全编程语言的选择,以保障系统的安全性。环境搭建基于Windows XP SP3和Kali Linux,使用Metasploit Framework进行攻击演示。请注意,此内容仅用于教育和研究目的。
77 4