Mac——命令行安装ftp安装包,最后安装lftp

一、lftp用法

lftp -f "open -u username,password ftp.example.com; put localfile.txt"
请将 "username,password" 替换为你的ftp登录凭证,"ftp.example.com" 替换为你的ftp服务器地址,"localfile.txt" 替换为你要上传的文件名。这将连接到ftp服务器并上传本地文件。

lftp链接FTP服务器:

lftp ftp://用户名:密码@IP地址

lftp 上传和下载文件的方法如下:

上传文件:

  1. 使用 put 命令上传单个文件,格式为 put [-E] [-a] [-c] [-O base] lfile [-o rfile] -o 指定上传后文件的名称,如果忽略,则使用本地文件的名字,另外名称里面不能有通配符。-c 使用这个参数可以续传或重新上传之前未传完或重新上传文件。-E 如果上传成功,则删除本地的文件(注意本地要备份好)。-a 使用ascii模式,如果忽略该参数,则使用二进制模式。-O 指定文件上传的目录,通常进入FTP服务器后可以使用CD来设置当前目录 ,所以该参数忽略,则使上传到当前目录。
  2. 使用 mput 命令上传多个文件,该命令用于批量文件上传,文件名中可以使用通配符比如files设置为 *,则意味着当前目录下的所有文件都要上传,包括目录以及目录里面的文件。它比put命令多一个参数就是-d。

下载文件:

  1. 使用 get 命令下载单个文件 下传多个普通文件 mget *
  2. 使用 mirror命令下载整个目录 mirror DIRNAME 【下载整个目录里包含子目录,推荐此命令】

在使用 lftp 命令时,请确保您已经连接到 FTP 服务器,并且具有足够的权限来执行上传和下载操作。

 

具体使用过程:

mayl@MacBook-Pro ~ %lftp ftp://mayl:12345678@192.168.3.230  #链接FTP服务器成功

lftp mayl@192.168.3.230:~> get 注册文件服务器.docx    #报错:是lftp在尝试获取文件时遇到了SSL/TLS证书验证错误。这可能是由于FTP服务器使用了一个自签名证书,而lftp客户端默认情况下可能会对这个类型的证书进行验证。解决此问题的一种方法是关闭lftp的SSL/TLS证书验证。这将使lftp忽略服务器的SSL/TLS证书,但也会使你的连接容易受到中间人攻击。这种方法应当仅在信任你的FTP服务器,并且了解潜在安全风险的情况下使用。在lftp中,你可以使用-e选项来临时关闭SSL/TLS证书验证。

get: 注册文件服务器.docx: 严重错误: Certificate verification: self-signed certificate (1E:91:90:86:47:16:96:7D:12:C4:AC:3F:0F:04:98:C2:3C:78:A5:0C)

lftp mayl@192.168.3.230:~> lftp -e "set ssl:verify-certificate no; get 注册文件服务器.docx" -u mayl,12345678 ftp://192.168.3.230    #报错:主要是文件名字不能包含汉字。

get: 访问失败: 501 Syntax error in parameters or arguments. (注册文件服务器.docx)     

lftp mayl@192.168.3.230:/> exit

mayl@MacBook-Pro ~ %lftp -e "set ssl:verify-certificate no; get 注册文件服务器.docx" -u mayl,12345678 ftp://192.168.3.230    #在外部命令行还是不行

get: 访问失败: 501 Syntax error in parameters or arguments. (注册文件服务器.docx)

mayl@MacBook-Pro ~ %lftp -e "set ssl:verify-certificate no; get 123.docx" -u mayl,12345678 ftp://192.168.3.230  #修改文件名字,成功传输

143979 bytes transferred           

lftp mayl@192.168.3.230:/> get 123.docx        #在内部再传,提示文件已存在

get: /Users/mayl/123.docx: 文件已经存在,并且 xfer:clobber 未被设置

lftp mayl@192.168.3.230:/> 

总结:

mayl@MacBook-Pro ~ %lftp -e "set ssl:verify-certificate no; get 1234.docx" -u mayl,12345678 ftp://192.168.3.230   #太长了,算了

143979 bytes transferred  

或者:

mayl@MacBook-Pro ~ %lftp -e "set ssl:verify-certificate no" ftp://mayl:12345678@192.168.3.230                   

lftp mayl@192.168.3.230:~> get 12345.docx

143979 bytes transferred 

或者:

mayl@MacBook-Pro ~ %lftp -e "set ssl:verify-certificate no" -u mayl,12345678 ftp://192.168.3.230                

lftp mayl@192.168.3.230:~> get 123456.docx

143979 bytes transferred  

或者:这种就是不行,必须要关闭lftp的SSL/TLS证书验证

mayl@MacBook-Pro ~ %lftp ftp://mayl:12345678@192.168.3.230                                                               

lftp mayl@192.168.3.230:~> get 1234567.docx

get: 1234567.docx: 严重错误: Certificate verification: self-signed certificate (1E:91:90:86:47:16:96:7D:12:C4:AC:3F:0F:04:98:C2:3C:78:A5:0C)

lftp mayl@192.168.3.230:~> 

 

 

 

 

 

二、安装:

mayl@MacBook-Pro ~ %ftp:\\192.168.3.230     #这是Windows用法

zsh: command not found: ftp:\192.168.3.230

mayl@MacBook-Pro ~ %ftp 192.168.3.230       #用法正确,但是,提示没有安装ftp

zsh: command not found: ftp

mayl@MacBook-Pro ~ %brew install ftp   #安装ftp,但是,没有可用的ftp包,于是可以选择安装其他ftp包

 

Running `brew update --auto-update`...

Warning: No available formula with the name "ftp". Did you mean lftp, uftp, fpp, fop, fcp, ntp or stp?

==> Searching for similarly named formulae and casks...

==> Formulae

bbftp-client          lftp                  proftpd               sftpgo                swiftplantuml         tnftpd                vsftpd                fop                   ntp

git-ftp               ncftp                 pure-ftpd             swift-protobuf        tnftp                 uftp                  fpp                   fcp                   stp

 

To install bbftp-client, run:

  brew install bbftp-client

 

==> Casks

classicftp             crushftp                 microsoft-powerpoint     minecraftpe              sipgate-softphone        swift-publisher          swiftplantumlapp         swiftpm-catalog

 

To install classicftp , run:

  brew install --cask classicftp

mayl@MacBook-Pro ~ %lftp          #验证是否已经安装过

zsh: command not found: lftp

mayl@MacBook-Pro ~ %brew install lftp  #安装lftp

Running `brew update --auto-update`...

Warning: You are using macOS 10.15.

We (and Apple) do not provide support for this old version.

It is expected behaviour that some formulae will fail to build in this old version.

It is expected behaviour that Homebrew will be buggy and slow.

Do not create any issues about this on Homebrew's GitHub repositories.

Do not create any issues even if you think this message is unrelated.

Any opened issues will be immediately closed without response.

Do not ask for help from Homebrew or its maintainers on social media.

You may ask for help in Homebrew's discussions but are unlikely to receive a response.

Try to figure out the problem yourself and submit a fix as a pull request.

We will review it but may or may not accept it.

 

==> Fetching lftp

==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/lftp-4.9.2_1.catalina.bottle.1.tar.gz

##################################################################################################################################################################################################### 100.0%

==> Pouring lftp-4.9.2_1.catalina.bottle.1.tar.gz

🍺  /usr/local/Cellar/lftp/4.9.2_1: 37 files, 3.3MB

==> Running `brew cleanup lftp`...

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

==> `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/bdw-gc/8.0.6... (69 files, 1.6MB)

Removing: /Users/mayl/Library/Caches/Homebrew/glib--patch--d81c9e8296ec5b53b4ead6917f174b06026eeb0c671dfffc4965b2271fb6a82c.diff... (905B)

Removing: /usr/local/Cellar/libevent/2.1.12... (57 files, 1.9MB)

Removing: /Users/mayl/Library/Caches/Homebrew/openssl@3--patch--e711cba257f08e3143a22cc7afbd550d76f2cf68ee5d251fadab4b0b5c44976a.patch... (949B)

Removing: /Users/mayl/Library/Caches/Homebrew/pixman--patch--391b56552ead4b3c6e75c0a482a6ab6a634ca250c00fb67b11899d16575f0686.patch... (128.1KB)

Removing: /usr/local/Cellar/unbound/1.15.0... (58 files, 5.8MB)

Removing: /usr/local/Cellar/zstd/1.5.2... (31 files, 3.1MB)

Removing: /Users/mayl/Library/Caches/Homebrew/python@3.11--patch--8bfe417c815da4ca2c0a2457ce7ef81bc9dae310e20e4fb36235901ea4be1658.diff... (1.8KB)

Removing: /Users/mayl/Library/Caches/Homebrew/python@3.11--patch--d1a29b3c9ecf8aecd65e1e54efc42fb1422b2f5d05cba0c747178f4ef8a69683.diff... (637B)

Removing: /Users/mayl/Library/Logs/Homebrew/aircrack-ng... (64B)

Removing: /Users/mayl/Library/Logs/Homebrew/libtiff... (6 files, 531.7KB)

Removing: /Users/mayl/Library/Logs/Homebrew/wget... (6 files, 2.2MB)

Removing: /Users/mayl/Library/Logs/Homebrew/xorgproto... (5 files, 134.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libidn2... (6 files, 1001.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libmagic... (6 files, 357.4KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libxau... (7 files, 213.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/little-cms2... (6 files, 338.4KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libpng... (8 files, 161.2KB)

Removing: /Users/mayl/Library/Logs/Homebrew/nettle... (9 files, 1.1MB)

Removing: /Users/mayl/Library/Logs/Homebrew/libxdmcp... (7 files, 212.8KB)

Removing: /Users/mayl/Library/Logs/Homebrew/cmake... (19 files, 5MB)

Removing: /Users/mayl/Library/Logs/Homebrew/freetype... (7 files, 392.8KB)

Removing: /Users/mayl/Library/Logs/Homebrew/imath... (7 files, 52.0KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libsamplerate... (13 files, 115.7KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libunistring... (9 files, 6.7MB)

Removing: /Users/mayl/Library/Logs/Homebrew/openjpeg... (7 files, 410.3KB)

Removing: /Users/mayl/Library/Logs/Homebrew/zimg... (7 files, 400KB)

Removing: /Users/mayl/Library/Logs/Homebrew/bdw-gc... (9 files, 288.8KB)

Removing: /Users/mayl/Library/Logs/Homebrew/nasm... (6 files, 705.9KB)

Removing: /Users/mayl/Library/Logs/Homebrew/util-macros... (4 files, 8.5KB)

Removing: /Users/mayl/Library/Logs/Homebrew/webp... (12 files, 1012.7KB)

Removing: /Users/mayl/Library/Logs/Homebrew/sqlite... (6 files, 171.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/xz... (7 files, 1.2MB)

Removing: /Users/mayl/Library/Logs/Homebrew/brightness... (64B)

Removing: /Users/mayl/Library/Logs/Homebrew/libnghttp2... (7 files, 325.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/fontconfig... (7 files, 541.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libvpx... (6 files, 618.2KB)

Removing: /Users/mayl/Library/Logs/Homebrew/snappy... (10 files, 115.0KB)

Removing: /Users/mayl/Library/Logs/Homebrew/openssl@3... (7 files, 6.9MB)

Removing: /Users/mayl/Library/Logs/Homebrew/ca-certificates... (111B)

Removing: /Users/mayl/Library/Logs/Homebrew/zstd... (7 files, 542.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/libevent... (8 files, 693.2KB)

Removing: /Users/mayl/Library/Logs/Homebrew/openssl@1.1... (7 files, 3.6MB)

Removing: /Users/mayl/Library/Logs/Homebrew/leptonica... (6 files, 1.4MB)

Removing: /Users/mayl/Library/Logs/Homebrew/doxygen... (8 files, 895.5KB)

Removing: /Users/mayl/Library/Logs/Homebrew/unbound... (7 files, 1.2MB)

Removing: /Users/mayl/Library/Logs/Homebrew/guile... (6 files, 3.4MB)

Removing: /Users/mayl/Library/Logs/Homebrew/p11-kit... (9 files, 1.4MB)

Removing: /Users/mayl/Library/Logs/Homebrew/libatomic_ops... (9 files, 101.6KB)

Removing: /Users/mayl/Library/Logs/Homebrew/python@3.9... (16 files, 4.7MB)

Removing: /Users/mayl/Library/Logs/Homebrew/jpeg-turbo... (9 files, 828.2KB)

Removing: /Users/mayl/Library/Logs/Homebrew/gnutls... (6 files, 4.3MB)

Removing: /Users/mayl/Library/Logs/Homebrew/dnsmasq... (3 files, 43.2KB)

Pruned 0 symbolic links and 5 directories from /usr/local

posted @ 2023-09-08 16:15  马踏飞燕Beautiful  阅读(2165)  评论(0编辑  收藏  举报