官方文档

https://cloud.tencent.com/document/product/436/7214

官方github

需要先到github 下载ftp服务包

https://github.com/tencentyun/cos-ftp-server-V5

安装部署

进入安装目录,运行setup.py 脚本,机器需要连网

1  

|

sudo python setup.py install  
  

—|—

修改配置文件

进入到下载目录下的conf文件下里
将vsftpd.conf.example文件重新复制一份命名为vsftpd.conf

以下为配置文件说明:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  

|

[COS_ACCOUNT_0]  
cos_secretid = COS_SECRETID    # 替换为您的 SECRETID  
cos_secretkey = COS_SECRETKEY  # 替换为您的 SECRETKEY  
cos_bucket = examplebucket-1250000000  
cos_region = region   # 替换为您的存储桶地域  
cos_protocol = https  
#cos_endpoint = region.myqcloud.com  
home_dir = /home/user0   # 本机要有此目录  
ftp_login_user_name=user0  # ftp 所用的用户名  
ftp_login_user_password=pass0 #ftp 所用的密码  
authority=RW  
delete_enable=true                    # true 为允许该 ftp 用户进行删除操作(默认),false 为禁止该用户进行删除操作  
  
[COS_ACCOUNT_1]  
cos_secretid = COS_SECRETID    # 替换为您的 SECRETID  
cos_secretkey = COS_SECRETKEY  # 替换为您的 SECRETKEY  
cos_bucket = examplebucket-1250000000  
cos_region = region   # 替换为您的存储桶地域  
cos_protocol = https  
#cos_endpoint = region.myqcloud.com  
home_dir = /home/user1  #此目录不能与上个目录一样  
ftp_login_user_name=user1  
ftp_login_user_password=pass1  
authority=RW  
delete_enable=false  
  
[NETWORK]  
masquerade_address = XXX.XXX.XXX.XXX        # 如果 FTP SERVER 处于某个网关或NAT后,可以通过该配置项将网关的IP 地址或域名指定给 FTP  
listen_port = 2121                       # Ftp Server的监听端口,默认为2121,注意防火墙需要放行该端口  
  
passive_port = 60000,65535             # passive_port 可以设置 passive 模式下,端口的选择范围,默认在(60000, 65535)区间上选择  
  
[FILE_OPTION]  
# 默认单文件大小最大支持到200G,不建议设置太大  
single_file_max_size = 21474836480  
  
[OPTIONAL]  
# 以下设置,如无特殊需要,建议保留 default 设置  如需设置,请合理填写一个整数  
min_part_size       = default  
upload_thread_num   = default  
max_connection_num  = 512  
max_list_file       = 10000                # ls命令最大可列出的文件数目,建议不要设置太大,否则ls命令延时会很高  
log_level           = INFO                 # 设置日志输出的级别  
log_dir             = log                  # 设置日志的存放目录,默认是在ftp server目录下的log目录中  
  

—|—
`

以下为我的配置文件:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  

|

[COS_ACCOUNT_alaudaace]  
cos_secretid = AKIDj2Axxxxxxxxxxxxxxxxxxxxxxxxx  
cos_secretkey = 4uUpvlxxxxxxxxxxxxxxxx  
cos_bucket = alauda-xxxxxxxx  
cos_region = ap-cxxxg  
cos_protocol = https  
#cos_endpoint = ap-xxx.myqcloud.com  
home_dir = /home/alxx  
ftp_login_user_name = alaxxe  
ftp_login_user_password = cExxxxxx  
authority = R  
delete_enable = false  
  
[COS_ACCOUNT_alauda]  
cos_secretid = AKIDj2Axxxxxxxxxxxxxxxxxxx  
cos_secretkey = 4uUpvldxxxxxxxxxxxx  
cos_bucket = alauda-xxxxx  
cos_region = ap-chongqing  
cos_protocol = https  
#cos_endpoint = ap-xxx.myqcloud.com  
home_dir = /home/xx   
ftp_login_user_name = xx  
ftp_login_user_password = kjsxxxx  
authority = R  
delete_enable = false  
  
#[COS_ACCOUNT_3]  
#cos_secretid = XXXX  
#cos_secretkey = XXXXX  
#cos_bucket = {bucket name}-123  
#cos_region = ap-xxx  
#cos_protocol = https  
##cos_endpoint = ap-xxx.myqcloud.com  
#home_dir = /home/user1  
#ftp_login_user_name=user1  
#ftp_login_user_password=pass1  
#authority=RW  
#delete_enable=true  
  
[NETWORK]  
masquerade_address = 11xxx ## 注:此处写本ftp服务器的外网IP  
listen_port = 2121  
  
#passive_port可以设置passive模式下,端口的选择范围,默认在(60000, 65535)区间上选择  
passive_port = 60000,65535  
  
[FILE_OPTION]  
# 默认单文件大小最大支持到200G,不建议设置太大  
single_file_max_size = 214748364800  
  
[OPTIONAL]  
config_check_enable = true  
  
# 以下设置,如无特殊需要,建议保留default设置  如需设置,请合理填写一个整数  
min_part_size       = default  
upload_thread_num   = default  
max_connection_num  = 100  
max_list_file       = 10000  
log_level           = DEBUG  
log_dir             = log  
  

—|—

运行 ftp_server.py 启动 FTP Server:

  • 前台运行

    1

|

python ftp_server.py  
  

—|—

  • 后台运行

    1

|

nohup python ftp_server.py >> /dev/null 2>&1 &  
  

—|—

  • 使用screen运行

    1
    2
    3
    4
    5

|

screen -dmS ftp  
screen -r ftp  
python ftp_server.py  
#使用快捷键,切回主 screen 即可:  
Ctrl+A+D   
  

—|—

网络及安全设置

  • 机器所在的安全组需要放开2121,60000-65535端口

  • 机器上的iptables需要放行

    1  
    2
    

|

    iptables -A INPUT -p tcp --dport 2121 -j ACCEPT  
    iptables -A OUTPUT -p tcp --dport 2121 -j ACCEPT  
      

—|—

常见问題解决

https://cloud.tencent.com/document/product/436/30742

使用客户端下载

https://filezilla-project.org/index.php

或其它客户端,请自行下载

使用浏览器访问

ftp://118.xxxx xxxx:2121

输入对应的帐号及密码即可

ace下载

  • 服务器地址:11xxxx xxx
  • 服务器端口:2121
  • 用户名:alauxxxx
  • 密码:cxxxx x

acp下载

  • 服务器地址:118xxx
  • 服务器端口:2121
  • 用户名:alauda
  • 密码:kjshxxxx

安装包上传到腾讯oss

登陆打包机使用以下命令上传

|

pip install coscmd  
  

—|—

  • 上传前请修改配置,上传acp就把acp打开即可

    1  
    2  
    3  
    4  
    5  
    6  
    7  
    8  
    9  
    10
    

|

    cat ~/.cos.conf  
      [common]  
      secret_id = AKIDjxxxxxxxxxxxxxxxxxxxxxx  
      secret_key = 4uUpxxxxxxxxxxxxx  
      # bucket = alauda-xxxxxxxxxxx  
      bucket = alauda-xxxxxxxxxxxxxx4  
      region = ap-chongqing  
      max_thread = 5  
      part_size = 1  
      schema = https  
      

—|—

  • 命令格式:

    1
    

|

    coscmd upload <localpath> <cospath>  —skipmd5 (这个参数为跳过md5检查)  
      

—|—

  • 示例:

    1
    

|

    coscmd upload --skipmd5 acp-2.0.1-190703.tgz  /  
      

—|—

  • 官方命令文档

https://cloud.tencent.com/document/product/436/10976