阿里云七天打卡day01

简介: 根据阿里云使用,基于ECS搭建FTP课程实验项目过程编写此文章具体过程有1. 创建资源2. 远程连接ECS服务器3. 安装vsftpd4. 配置vsftpd5. 客户端测试

创建资源

  1. 在页面左侧,单击 云产品资源 下拉菜单,查看本次实验资源。
  2. 单击 免费开通 创建所需资源。
    image.png

得到一上图片即为成功创建实例

远程连接服务器

接下来即可开始第二步
yu
远程连接ECS服务器 推荐使用XShell
此文章中使用windows自带的CMD实现

在CMD中输入 ssh -V可查看是否拥有ssh,如下图所示例
image.png

否则需要只能装openSSH
链接https://www.mls-software.com/files/setupssh-8.2p1-1.exe?spm=a2c6h.13858378.0.0.5f2992d3oUyHvH&file=setupssh-8.2p1-1.exe

然后在终端中输入连接命令 ssh [username]@[ipaddress]。将其中的 username 和 ipaddress 替换为云产品资源提供的ECS服务器的 用户和 弹性IP。例如:ssh root@123.123.123.123

示例image.png
输入yes(注意 不是y)

image.png
如上即为连接成功 其中 输入密码时 密码不会显示 注意正确性

安装vsftpd

接下来进行安装vsftp

yum install -y vsftpd

如图所示即成功

image.png

配置FTP启动服务(注意是开机自启动)

image.png

systemctl enable vsftpd.service

接下来启动ftp

systemctl start vsftpd.service

运行以下代码实现查看启动状态

image.png
可以看到端口是21

配置vsftpd

image.png

# 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

即可查看文件

按i即可进入编辑模式

文章中已经写了

#anon_upload_enable=YES

所以去掉前面的#号即可

接下来按ESC退出文件编辑模式

:wq

前面一定有 : 号 (注意)

然后更改目录权限,为FTP用户添加写权限

image.png

chmod o+w /var/ftp/pub/

做完之后重启FTP服务。如下图。

systemctl restart vsftpd.service

image.png

为FTP服务创建一个Linux用户。

adduser ftptest

并且设置密码

image.png

创建一个供FTP服务使用的文件目录。
这个地方要注意,否则上传会出问题

更改/var/ftp/test目录的拥有者为ftptest。

新建一个文件夹供使用

image.png
配置FTP为主动模式执行如下命令:
image.png

我这里使用的是主动模式,如图
被动和主动已经放在这里了
配置FTP为主动模式请执行如下命令:

sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf #禁止匿名登录FTP服务器 
sed -i 's/listen=NO/listen=YES/' /etc/vsftpd/vsftpd.conf #监听IPv4 sockets 
sed -i 's/listen_ipv6=YES/#listen_ipv6=YES/' /etc/vsftpd/vsftpd.conf #关闭监听IPv6 sockets 
sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/' /etc/vsftpd/vsftpd.conf #全部用户被限制在主目录 
sed -i 's/#chroot_list_enable=YES/chroot_list_enable=YES/' /etc/vsftpd/vsftpd.conf #启用例外用户名单 
sed -i 's/#chroot_list_file=/chroot_list_file=/' /etc/vsftpd/vsftpd.conf #指定例外用户列表文件,列表中的用户不被锁定在主目录 
echo "allow_writeable_chroot=YES" >> /etc/vsftpd/vsftpd.conf 
echo "local_root=/var/ftp/test" >> /etc/vsftpd/vsftpd.conf #设置本地用户登录后所在的目录

配置FTP为被动模式请执行如下命令:

sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf #禁止匿名登录FTP服务器 
sed -i 's/listen=NO/listen=YES/' /etc/vsftpd/vsftpd.conf #监听IPv4 sockets 
sed -i 's/listen_ipv6=YES/#listen_ipv6=YES/' /etc/vsftpd/vsftpd.conf #关闭监听IPv6 sockets 
sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/' /etc/vsftpd/vsftpd.conf #全部用户被限制在主目录 
sed -i 's/#chroot_list_enable=YES/chroot_list_enable=YES/' /etc/vsftpd/vsftpd.conf #启用例外用户名单 
sed -i 's/#chroot_list_file=/chroot_list_file=/' /etc/vsftpd/vsftpd.conf #指定例外用户列表文件,列表中的用户不被锁定在主目录 
echo "allow_writeable_chroot=YES" >> /etc/vsftpd/vsftpd.conf 
echo "local_root=/var/ftp/test" >> /etc/vsftpd/vsftpd.conf #设置本地用户登录后所在的目录 

echo "pasv_enable=YES" >> /etc/vsftpd/vsftpd.conf #开启被动模式 
echo "pasv_address=<FTP服务器公网IP地址>" >> /etc/vsftpd/vsftpd.conf #本教程中为ECS服务器弹性IP 
echo "pasv_min_port=20" >> /etc/vsftpd/vsftpd.conf #设置被动模式下,建立数据传输可使用的端口范围的最小值 
echo "pasv_max_port=21" >> /etc/vsftpd/vsftpd.conf #设置被动模式下,建立数据传输可使用的端口范围的最大值

文件创建编写之前已经做过了

这个文件有个关键点,他可以为空,但是必须有

再次重启服务

systemctl restart vsftpd.service

客户端测试

这里使用的是命令行,也可以使用Chrome浏览器
我在浏览器测试的时候是没有反应的,可能是因为一下浏览器设置的原因
image.png

目录
相关文章
|
缓存 网络协议 安全
如何在阿里云使用 DNSSEC
DNSSEC(Domain Name System Security Extensions)是互联网上增强域名系统(DNS)安全性的一种解决方案。DNSSEC 的主要目的是解决 DNS 缓存投毒和 DNS 欺骗攻击等问题,其通过在 DNS 中增加数字签名的方式确保 DNS 记录的一致性和可靠性。DNSSEC 的广泛使用可以有效地增强网络安全性,提高用户数据的保护和隐私。
751 0
|
人工智能 弹性计算 分布式计算
阿里云之路
阿里云创立于2009年,是全球领先的云计算及人工智能科技公司,致力于以在线公共服务的方式,提供安全、可靠的计算和数据处理能力,让计算和人工智能成为普惠科技。阿里云服务着制造、金融、政务、交通、医疗、电信、能源等众多领域的领军企业,包括中国联通、12306、中石化、中石油、飞利浦、华大基因等大型企业客户,以及微博、知乎、锤子科技等明星互联网公司。在天猫双11全球狂欢节、12306春运购票等极富挑战的应用场景中,阿里云保持着良好的运行纪录。
193 1
|
弹性计算 安全 运维
阿里云学生计划
阿里云有一个云翼计划,学生新用户可以有两个月的阿里云服务器使用权,首先需要先进行学生认证,然后通过一个进入阿里云高校学生计划,进行学习和测试。
933 1
|
弹性计算 Linux Docker
阿里云的使用总结
阿里云非常优秀
|
大数据 Linux
阿里云对我的帮助
讲述阿里云对我的帮助,让我学会Linux、HTML等相关知识。
134 0
|
弹性计算 数据可视化 物联网
初识阿里云
为了解、学习Linux的用法,以及在服务器上部署数据库等,为此租用阿里云服务器进行学习和项目上线
338 0
|
弹性计算 前端开发 开发者
使用阿里云的心得
使用阿里云的心得
|
弹性计算 安全 网络安全
我于阿里云的初识
通过阿里云app的推送,我参加了阿里云现在支持大学生的飞天加速计划,因此试用了一下ECS服务器,接下来我就介绍一下我自己,以及对服务器的使用做一个小小的经验分享。
我于阿里云的初识
|
Kubernetes 监控 容器
阿里云冬季训练营
零基础容器技术实战
141 1
|
安全 Java 物联网
第一次使用阿里云
分享一下最近使用阿里云的一些感受和使用方法,还有就是做使用过程中遇到的一些问题。非常感谢阿云的这个飞天加速计划,对学生来说太友好了。
313 0