Linux 代理背后的基于文本的 FTP 客户端设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5334110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:17:04  来源:igfitidea点击:

Text based FTP client settings behind a proxy

linuxproxyftpfedora

提问by schone

I need to create a bash script which will connect to an FTP server, upload a file and close the connection. Usually this would be an easy task but I need to specify some specific proxy settings which is making it difficult.

我需要创建一个 bash 脚本,该脚本将连接到 FTP 服务器、上传文件并关闭连接。通常这将是一项简单的任务,但我需要指定一些特定的代理设置,这使得它变得困难。

I can connect to the FTP fine using a GUI client i.e. Filezilla with the following settings:

我可以使用具有以下设置的 GUI 客户端(即 Filezilla)连接到 FTP:

Proxy Settings
--------------
FTP Proxy : USER@HOST
Proxy Host: proxy.domain.com
Proxy User: blank
Proxy Pass: blank

Proxy Settings

代理设置

FTP Settings
------------
Host : 200.200.200.200
Port : 21
User : foo
Pass : bar

FTP Settings

FTP 设置

What I can't seem to do is replicate these settings within a text based ftp client i.e. ftp, lftp etc. Can anyone help with setting this script up?

我似乎无法做的是在基于文本的 ftp 客户端(即 ftp、lftp 等)中复制这些设置。任何人都可以帮助设置此脚本吗?

Thanks in advance!

提前致谢!

采纳答案by Mikel

According to the docs, lftpshould support the ftp_proxyenvironment variable, e.g.

根据文档lftp应该支持ftp_proxy环境变量,例如

ftp_proxy=ftp://proxy.domain.com lftp -c "cd /upload; put file" ftp://200.200.200.200

If that works, you can put

如果这有效,你可以把

export ftp_proxy=ftp://proxy.domain.com

in your shell configuration files, or

在您的 shell 配置文件中,或

set ftp:proxy=ftp://proxy.domain.com

in your ~/.lftprc.

在你的 ~/.lftprc 中。

Alternatively, try running the commands that your GUI FTP client is running, e.g.

或者,尝试运行您的 GUI FTP 客户端正在运行的命令,例如

upload.lftp

上传.lftp

USER ...@...
PASS ...
PUT ...

And run it using -s:

并使用-s

lftp -s upload.lftp 200.200.200.200

Or try curl -T(docs) ncftpput(docs).

或尝试curl -T( docs) ncftpput( docs)。

Something like:

就像是:

FTP_PROXY=ftp://proxy.domain.com curl -T uploadfile -u foo:bar ftp://200.200.200.200/myfile

might work.

可能工作。