阻止 lf​​tp 在传输文件时发出“CWD /”的方法

阻止 lf​​tp 在传输文件时发出“CWD /”的方法

给出lftp类似于以下内容的命令:

lftp -vv -d -c set ssl:ca-file /path/to/cert/ftps_cron-bundle.crt; set ssl:check-hostname no; set ftp:ssl-protect-data true; set sftp:connect-program "ssh -a -x -o PubkeyAuthentication=no"; set net:max-retries 2; open -e 'put /path/to/data/upload.txt;' -u username:password ftps://server.example.net/

该命令模板适用于各种服务器,但在一台服务器上,即使上传成功,也会显示错误消息:

---- CWD path to be sent is `/'
<--- 200 Command OPTS succeed
---> CWD /
<--- 550 Permission denied
cd: Access failed: 550 Permission denied (/)

如何阻止lftp发送CWD /到该服务器?

<--- 230 User logged in
---> FEAT
<--- 211-Extensions supported
<---     SIZE
<---     XMD5
<---     XSHA1
<---     XSHA256
<---     XSHA512
<---     XQUOTA
<---     LANG EN, ES, FR, GE
<---     MDTM
<---     MLST size*;type*;perm*;create*;modify*;
<---     REST STREAM
<---     TVFS
<---     UTF8
<---     AUTH SSL;TLS-P;
<---     PBSZ
<---     PROT C;P;
<--- 211 end
---> PWD
<--- 257 "/username/folder" is current directory
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 PRIVATE data channel protection level set
---> LANG
<--- 200 Default languages set to EN
---> OPTS UTF8 ON
<--- 200 Command OPTS succeed
---> OPTS MLST size;type;perm;modify;
---- CWD path to be sent is `/'

请注意,服务器会根据用户名自动设置其默认上传目录……即/username/folder

上传应该会转到此默认上传目录,而不会生成错误消息。它确实上传了,但日志显示了错误消息:

cd: Access failed: 550 Permission denied (/)
---> TYPE I
<--- 200 Transfer mode set to BINARY
---> PASV
<--- 227 Entering Passive Mode (10,10,35,21,195,225).
---- Address returned by PASV seemed to be incorrect and has been fixed
---- Connecting data socket to (nnn.nnn.nnn.nnn) port 50145
---- Data connection established
---> ALLO 148891
<--- 200 Command ALLO succeed
---> STOR upload.txt
<--- 150 Uploading in BINARY file upload.txt
Certificate: ...
Issued by: ...
Trusted
WARNING: Certificate verification: hostname checking disabled
---- Closing data socket
<--- 226 Transfer completed
---> SITE UTIME 20190819100016 upload.txt
<--- 550 Command SITE failed
---> QUIT
---- Closing control socket

尝试了很多方法。例如,使用 put 命令的各种路径。

  • put -O . /path/to/data/upload.txt
  • put -O /username/folder /path/to/data/upload.txt

cd /username/folder还尝试明确地发出命令。

删除-vv-d也是无效的。

如何才能lftp避免自动发出CWD /不必要的、令人困惑的错误消息,而该消息实际上并不意味着任何事情都失败了?

$ lftp --version
LFTP | Version 4.4.8 | Copyright (c) 1996-2013 Alexander V. Lukyanov
...
Libraries used: Readline 6.2

答案1

在 URL 末尾附加波浪符号 (~):

ftps://server.example.net/~

或者,直接删除结尾的斜杠:

ftps://server.example.net

相关内容