ftp服务平时用的非常多,像服务器上传文件,客户端工具如:FileZila、Winscp,服务器软件如:FileZila server(搭建简单) 、IIS (搭建自己觉的挺麻烦)、vsftpd(linux 简单)
ftp分ftp客户端和ftp服务端,这里先介绍ftp客户端。
使用ftp客户端的时候,经常需要把 本地【防火墙】 关闭,否则使用不了。
1. ftp客户端
ftp客户端使用,一般ftp客户端
软件名称 | 支持的平台 | 是否有服务端 | 是否支持SCP |
---|---|---|---|
Winscp | windows | false | 是 |
Filezila client | all platform | false | 是 |
FTP | all platform | false | 是 |
SFTP | all platform | false | 是 |
1.1 winscp
或者直接用scp命令搞定
1.2. fileZila 客户端工具
fileZila作为ftp客户端,支持所有平台,跨平台,支持 macos、window
fileZila server 同时支持 主动和被动模式
fileZila server 中文版
FileZilla Server安装配置教程
filezilla server 下载、安装、配置教程 【端口值设置 31000~31010就可以、证书不用添加】
阿里云上面主要要在安全组
的入方法
开通21
和31000~31010
的端口,否则导致连接不上。
2 ftp服务器端
2.1 ftp服务端概要
2.1.1、ftp软件说明:
ftp软件名称 | 使用环境 | 安装难度 | ftp or sftp | 安装示例 |
---|---|---|---|---|
filezila server | only windows | easy | ftp | test189.ourslook.com |
vsftpd | only linux | easy | ftp 和 sftp都支持 | 39.98.173.142 (图书服务器) |
ceph | only linux | hard | ||
fastdfs | only linux | hard |
2.1.2、服务器端口开放说明:
端口 | 作用 | 详细说明 |
---|---|---|
21 | ftp主端口 | 开通之后浏览器ftp://localhost 就可以访问了 |
22 | sftp必须开通 | SFTP - SSH File Transfer Protocol 加密的ftp必须开通22,如:vsftp |
30000~30100,阿里云格式:30000/30100 | ftp-被动模式~随机端口n |
2.1.3、服务器ftp的目录说明
访问方式 | 密码 | 路径 | 备注 |
---|---|---|---|
ftp 或者anonymous | 空 | 默认/var/ftp/ | 通过ftp登录,查看:pwd 、ls -l 可以查看该命令 |
root | 自己设置的密码 | 如:/home/root | |
ftpuser | 自己设置的密码,eg: ftpx123.pwd..1 | 如:/home/ftpuser |
2.1.4、主动模式和被动模式区别
参见:FTP与SFTP两者有什么区别
简言:
主动模式
:是客户端开随机端口
被动模式
:是服务器开随机端口
2.1.5 访问用户根目录之外的目录
原因:磁盘大小有限制,只能加大磁盘,或者挂载。
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 退出
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
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 是否运行匿名访问
- read only 允许未经认证的访问
- write only 允许未经认证的上传
- read+write 允许读写
- none 默认值,必须经过认证
4.2 【sts】 【临时授权】
- 支持对url进行鉴权:【sts】【临时授权】 【Presigned presignedGetObject 预签】MinIO STS快速入门指南
- minio SDKS Java Client API参考文档