使用Mac ftp命令连接操作阿里云FTP

背景说明

需要将本地的数据,通过MacOS系统上传至阿里云FTP,此处将使用MacOS自带的命令行形式进行操作。

  • 本机系统:MacOS 10.15.2
  • FTP: 阿里云FTP

一、确认FTP环境

a@b:/usr/bin$ whereis ftp

表示无FTP命令。
下面安装FTP命令,确保拥有homebrew的安装环境。

二、安装FTP

Mac中使用FTP仅需要安装inetutils工具即可

a@b:/usr/bin$ brew install inetutils
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/libidn-1.38.catalina.bottle.tar.gz
Already downloaded: ~/Library/Caches/Homebrew/downloads/9af249221a404d7caa85e157ac945770eeb88ed3af0b8e54151a557b577ae48f--libidn-1.38.catalina.bottle.tar.gz
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/inetutils-2.2.catalina.bottle.tar.gz
Already downloaded: ~/Library/Caches/Homebrew/downloads/2d39696641e772d5731f3df871eda4d3b09c4b3be6c9706dff31e64b99905549--inetutils-2.2.catalina.bottle.tar.gz
==> Installing dependencies for inetutils: libidn
==> Installing inetutils dependency: libidn
==> Pouring libidn-1.38.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libidn/1.38: 73 files, 1MB
==> Installing inetutils
==> Pouring inetutils-2.2.catalina.bottle.tar.gz
==> Caveats
The following commands have been installed with the prefix 'g'.

    dnsdomainname
    ftp
    rcp
    rexec
    rlogin
    rsh
    telnet

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/inetutils/libexec/gnubin:$PATH"
==> Summary
🍺  /usr/local/Cellar/inetutils/2.2: 107 files, 3MB
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/gdbm/1.18.1_1... (25 files, 641KB)
Removing: /usr/local/Cellar/openssl@1.1/1.1.1i... (8,067 files, 18.5MB)
Removing: /usr/local/Cellar/readline/8.1... (48 files, 1.6MB)
Removing: /usr/local/Cellar/sqlite/3.34.0... (11 files, 4.1MB)
Pruned 0 symbolic links and 10 directories from /usr/local
==> Caveats
==> inetutils
The following commands have been installed with the prefix 'g'.

    dnsdomainname
    ftp
    rcp
    rexec
    rlogin
    rsh
    telnet

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/inetutils/libexec/gnubin:$PATH"

以上安装就完成了,下面配置环境变量。

三、配置环境变量

安装完毕后即提示ftp命令可以使用,并提示需要将PATH路径进行过配置。
按照以下操作配置变量

chenzy@fiboMBP004:~$ vim ~/.bash_profile

以下内容添加至文件内:
PATH="/usr/local/opt/inetutils/libexec/gnubin:$PATH"
export PATH

chenzy@fiboMBP004:~$ source ~/.bash_profile 

四、实操

非常开心的登录上阿里云FTP看看

a@b:~$ ftp
ftp> open a.ftp.aliapp.com
Connected to a.ftp.aliapp.com.
220 Welcome to FTP service.
Name (a.ftp.aliapp.com:a): b
331 Please specify the password.
Password: 
230 Login successful.
ftp> ls 
500 Illegal PORT command.
500 Unknown command.
425 Use PORT or PASV first.

突然出现了错误提示,并且任何命令个都提示500 Illegal PORT command. 500 Unknown command. 425 Use PORT or PASV first.
最后一行提示Use PORT or PASV first 指首先需要先指定操作是主动式或者被动式。

PORT-主动式:表示客户端在链路上,主动使用POST命令告诉服务端来连接
PASV-被动式:表示服务端在链路上,使用PASV命令客户端来连接

我们此处使用被动式

ftp> passive mode
Passive mode on.
ftp> ls
227 Entering Passive Mode .
150 Here comes the directory listing.
-r--r--r--    1 1   1        590 May 1  2019 README

这样FTP就可以使用啦

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

c_zyer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值