vsftpd 服务器搭建、ftp客户端filezilla使、ceph分布式文件系统

ftp服务平时用的非常多,像服务器上传文件,客户端工具如:FileZila、Winscp,服务器软件如:FileZila server(搭建简单) 、IIS (搭建自己觉的挺麻烦)、vsftpd(linux 简单)


ftp分ftp客户端和ftp服务端,这里先介绍ftp客户端。
使用ftp客户端的时候,经常需要把 本地【防火墙】 关闭,否则使用不了。

1. ftp客户端

 ftp客户端使用,一般ftp客户端 
软件名称支持的平台是否有服务端是否支持SCP
Winscpwindowsfalse
Filezila clientall platformfalse
FTPall platformfalse
SFTPall platformfalse
  1. filezilla client or server 跨平台做
  2. Winscp

1.1 winscp

​​windows scp demo
或者直接用scp命令搞定

1.2. fileZila 客户端工具

fileZila作为ftp客户端,支持所有平台,跨平台,支持 macos、window
fileZila server 同时支持 主动和被动模式

fileZila server 中文版
FileZilla Server安装配置教程
filezilla server 下载、安装、配置教程 【端口值设置 31000~31010就可以、证书不用添加】
filezila client1
filezila client 配置说明

filezila client 3

file zila client4
不管是主动还是备注都可以通过 浏览器直接打开
filezila 配置 被动模式 passive 动态端口设置
阿里云上面主要要在安全组入方法开通2131000~31010的端口,否则导致连接不上。
aliyun上面主要要开通两个端口

2 ftp服务器端

2.1 ftp服务端概要

2.1.1、ftp软件说明:

ftp软件名称使用环境安装难度ftp or sftp安装示例
filezila serveronly windowseasyftptest189.ourslook.com
vsftpdonly linuxeasyftp 和 sftp都支持39.98.173.142 (图书服务器)
cephonly linuxhard
fastdfsonly linuxhard

2.1.2、服务器端口开放说明:

端口作用详细说明
21ftp主端口开通之后浏览器ftp://localhost就可以访问了
22sftp必须开通SFTP - SSH File Transfer Protocol 加密的ftp必须开通22,如:vsftp
30000~30100,阿里云格式:30000/30100ftp-被动模式~随机端口n

2.1.3、服务器ftp的目录说明

访问方式密码路径备注
ftp或者anonymous默认/var/ftp/通过ftp登录,查看:pwdls -l可以查看该命令
root自己设置的密码如:/home/root
ftpuser自己设置的密码,eg: ftpx123.pwd..1如:/home/ftpuser

2.1.4、主动模式和被动模式区别

参见:FTP与SFTP两者有什么区别
简言:
主动模式:是客户端开随机端口
被动模式:是服务器开随机端口

2.1.5 访问用户根目录之外的目录

原因:磁盘大小有限制,只能加大磁盘,或者挂载。

vsftp访问FTP用户根目录以外的数据的实现方法

2.2. vsftp(very secure的ftp) 服务器软件

2.2.1 vsftp 服务器软件使用

vsftpd是linux一款sftp软件
windows搭建文件服务器,可以使用IIS(挺难搭建)、fileZila Server.
linux 我们使用:Vsftpd、fastdfs(淘宝 分布式文件系统)、Ceph s3、
ftp用户:ftpuser、ftpuser12

vsftpd安装命令特别简单:yum install -y vsftpd
ftp安装命令特别简单:yum install -y ftp <对vsftpd>验证有点问题,不支持sftp

  • FTP 服务大部分都是工作在主动模式下,filezila就使用的主动;vsftpd默认是主动模式。主动模式(【PORT】)和被动模式(PASV)

  • FTP Server需要开放21端口,client 通常关闭防火墙

  • vsftpd 默认主目录是“/var/ftp/”

  • vsftpd 中有三类用户:匿名用户、系统用户、虚拟用户

  • vsftpd 中配置文件目录:vim /etc/vsftpd/vsftpd.conf

  • 主动模式:服务器开放21、客户端开放随机端口n

  • 被动模式:服务器开放21和随机n【如限制:30000~30100】、客户端防火墙不用配置
    总结:服务器能干的事情,就服务器干了,一般选用被动模式
    如果服务器能开通 一个区间的端口,那就选用,被动模式。如果服务器开通端口很困难就是主动模式。

ftp://ourslook.com 使用的是filezila的主动模式,客户端要开放端口。
ftp://10.105.0.6使用的是vsftpd,服务器防火墙各种多,只能使用 被动访问。

Nginx 搭建图片服务器
vsftpd服务配置与管理(CentOS7)【非常详细】
vsftpd设置被动模式 【详细看】
vsftpd 常用功能参数配置及参数详解 Table of Contents
参考-linux上搭建nginx+ftp,实现文件的上传与访问

###########################
#查看vsftpd是否已经启动
设置永久启动(开机自启动) #  chkconfig vsftpd on
 查看状态# service vsftpd status
开启:# service vsftpd start
关闭:# service vsftpd stop
重启:# service vsftpd restart

2.2.2 vsftpd 匿名用户

vsftpd默认使用的是匿名用户,默认账号:anonymous 和 ftp,无需输入密码,但必须输入账号.
在生产环境中,建议设置“anonymous_enable=NO”,关闭匿名访问模式,安全隐患比较大。
#ftp的使用; 【【如果 ftp 测试一直 失败报错。但是本机可以。 请用 SFTP 或者 FileZila测试】】
# 测试ftp是否已经安装
# 浏览器直接输入:ftp://localhost/   或者具体ip: ftp://10.105.0.6/
ftp localhost #测试,如果没有安装,请先按照 yum install -y ftp;
[root@iot_server_test ftp]# ftp localhost
Name (localhost:root): ftp  #匿名ftp,输入ftp或者anonymous;换行之后输入密码,没有密码直接回车; 如果是:系统用户,输入eg: ftpuser, 输入密码
ftp> bye #输入bye 或者 quit 退出

ftp匿名
ftp 需要密码
ftp 报错 解决 方案
FTP 和 sftp 连接 vsftpd

2.2.3 vsftpd 系统用户

使用匿名用户,有安全风险,我们新建一个系统用户,防止系统用户被泄露。
# 创建一个用户,设置不运行远程登录
[root@server ~]# useradd ftpuser 
[root@server ~]# #useradd -d /home/ftpuser -m ftpuser # 【目前目录必须是/home,文件比较大,请注意扩从磁盘】 创建第二种;创建一个用户同时指定家目录,设置不能登录 ; userdel -r ftpuser #删除用户以及用户级联的文件。把 用户目录 链接 到 其他目录:/usr/local/ftp;
# -d: 指定目录 
# -s: 指定shell 为不能登录shell
# -m: 可以允许非 /home/xx目录,作为用户的主目录。
# 如果提示 vsftp上传553 Could not create file错误解决:sudo chmod -R 777 /home/ftpuser/ftp
useradd -d /usr/local/ftp -m ftpuser
[root@server ~]# passwd ftpuser #修改ftp用户密码,设置为:ftpx123.pwd..1 
[root@server ~]# echo "ftpx123.pwd..1"  |passwd   --stdin ftpuser#修改密码第二种,可以 
[root@server ~]# echo ‘我是 ftp test’ > /home/ftpuser/ftptest.txt  #在ftpuser用户主目录,随便放一个测试文件,并写入文字
[root@server ~]# ln -s /usr/local/ftp /home/ftpuser/ #设置软连接, ln -s 源文件 目标文件; 这样,我们上传到ftp目录,解决系统目录磁盘小的问题。  rm -rf 目标链接; 
#切换用户家目录
[root@server ~]# vim /etc/passwd #修改完成,保存就可以了
# 如果磁盘空间不足,那就成重新添加一块磁盘挂载到/home把
# vim /etc/vsftpd/vsftpd.conf
# vsftdp默认同时开通主动模式、被动模式; 
# 主动,请客户端关闭电脑所有防火墙、可能还有杀毒软件防火墙
# 被动,请关闭服务器防火墙,或者 同时打开 服务器和云服务器厂商的31000~31010端口
# 如果配置一直出问题,请先用匿名的测试一下。然后在开需要密码访问
# Example config file /etc/vsftpd/vsftpd.conf
# 已经删除无用的注释
# 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=NO  
#
# 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
#local_root=/home/ftpuser/ftp
#
# 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. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# 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_list_enable=NO #将系统用户禁锢于指定的目录中,禁止其随意切换,如切换到 /etc目录带来系统隐患,line = 101,启用该项;重启,虽然还可以访问/var/ftp目录,但pwd看到是“/”
# (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=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES


pasv_min_port=31000 #被动模式最低端口
pasv_max_port=31010 #被动模式最高端口


#记得要重启:service vsftpd restart
测试ftp安装情况

2.2.4 vsftpd 虚拟用户

使用系统用户,如果系统用户泄露,会导致安全问题。配置虚拟用户稍微复杂。
这里我们就使用系统用户把

2.2.5 映射用户目录

/home/ 目录一般不方便扩展磁盘,我们把 新磁盘目录 挂载到 home目录。解决 home目录空间太小的问题;   
⚠️⚠️ 测试这种方式失败,上传失败。
#挂载local2 到 =》 home:
> mount --bind /usr/local2/ftpuser/ftp /home/ftpuser/ftp   #格式:mount [-参数] [设备名称] [挂载点]

#查看所有挂载点:
> cat /etc/mtab
#卸载挂载点:
> umount /usr/local2/ftpuser/ftp 或者 umount /home/ftpuser/ftp #卸载可以是[设备名称] 也可是[挂载点]

#修改文件所属人和组: 
> chown ftpuser.ftpuser default/

3、ceph分布式文件系统

ceph

参考1:基于docker部署ceph以及修改docker-image
参考2:ceph存储,使用docker部署
参考3:使用docker 搭建 ceph 开发环境,使用aws sdk 存储数据
参考4: Ceph基础篇视频课程

4、minio

4.1 是否运行匿名访问

  1. read only 允许未经认证的访问
  2. write only 允许未经认证的上传
  3. read+write 允许读写
  4. none 默认值,必须经过认证
    匿名访问策略

MINIO运行匿名访问

4.2 【sts】 【临时授权】

  1. 支持对url进行鉴权:【sts】【临时授权】 【Presigned presignedGetObject 预签】MinIO STS快速入门指南
  2. minio SDKS Java Client API参考文档

5、fastdfs

6、aliyun oss

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,下面是在Linux中利用yum安装vsftpd并搭建ftp服务器的步骤: 1. 安装vsftpd 在终端中输入以下命令: ```sudo yum install vsftpd``` 2. 启动vsftpd服务 在终端中输入以下命令: ```sudo systemctl start vsftpd``` 3. 设置vsftpd服务开机自启动 在终端中输入以下命令: ```sudo systemctl enable vsftpd``` 4. 配置vsftpd 编辑vsftpd配置文件/etc/vsftpd/vsftpd.conf,修改以下参数: ```anonymous_enable=NO #禁用匿名登录 local_enable=YES #允许本地用户登录 write_enable=YES #允许用户上传文件 local_umask=022 #设置上传文件的权限 chroot_local_user=YES #限制用户只能访问自己的家目录 user_sub_token=$USER #创建用户家目录时,用用户名作为目录名 local_root=/home/$USER/ftp #设置ftp根目录为用户家目录的ftp子目录 ``` 5. 创建ftp用户 在终端中输入以下命令: ```sudo adduser ftpuser``` 然后输入密码和其他信息。 6. 设置ftp用户的家目录 在终端中输入以下命令: ```sudo usermod -d /home/ftpuser ftpuser``` 这里将ftp用户的家目录设置为/home/ftpuser。 7. 创建ftp目录 在终端中输入以下命令: ```sudo mkdir /home/ftpuser/ftp``` 这里创建/home/ftpuser/ftp目录用于存放ftp用户上传的文件。 8. 修改ftp目录权限 在终端中输入以下命令: ```sudo chown nobody:nogroup /home/ftpuser/ftp``` 这里将ftp目录的属主和属组都设置为nobody:nogroup,以免出现权限问题。 9. 重启vsftpd服务 在终端中输入以下命令: ```sudo systemctl restart vsftpd``` 至此,ftp服务器已经搭建完成,可以使用ftp客户端连接服务器进行文件传输了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dazer007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值