【问题标题】:Implicit TLS FTP connection using WinSCP or other command line FTP client in Windows在 Windows 中使用 WinSCP 或其他命令行 FTP 客户端的隐式 TLS FTP 连接
【发布时间】:2014-04-29 22:12:35
【问题描述】:

我需要从命令行连接到使用隐式 TLS、用户名和密码保护的 FTP,以便稍后创建批处理。我正在使用 WinSCP,因为它是最受欢迎的(我认为),或者根据广泛的谷歌搜索,我可以使用它来实现这一目标。我不是专家,但阅读了我目前拥有的文档,但从命令提示符连接不成功:

winscp> open username:password@host:port -implicit -certificate="aa:aa:aa:aa..."

一旦连接,我需要将那里的所有内容提取到文件夹 \hostname\folder 或 c:\folder 然后删除 ftp 上的文件(或多或少像 cut)

【问题讨论】:

  • 我可以使用 filezilla 和 gui winscp(使用相同的凭据)进行连接,但我需要从 cli 进行连接,以便我可以自动化该过程。

标签: windows ssl ftp command-line-interface winscp


【解决方案1】:

感谢 Martin Prikryl 的纠正,我能够连接,这就是我所做的:

使用 winscp.com 命令“connection.txt”创建了一个文本文件:

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect with username and password
open ftp://username:password@host:port -implicit -certificate="aa:aa:aa:aa...."
# Change local directory
lcd C:\local_working_folder
# Force binary mode transfer
option transfer binary
# Download missing files to local directory from remote
synchronize local
# Delete all remote files
rm *
# Disconnect
close
# Exit WinSCP
exit

现在从命令提示符或批处理文件中,您只需从安装位置调用 winscp.exe。如果从安装媒体中提取,则应该是 C:\Program Files\WinSCP\WinSCP.exe,如果从 .zip 便携版本中提取,则指向您提取文件的文件夹:

C:\WinSCP\WinSCP.exe /console /script="connection.txt" /log="conn.log"

然后只需安排批处理以自动化该过程。

【讨论】:

    【解决方案2】:

    您的语法几乎是正确的。您只缺少协议前缀ftp://(请注意,WinSCP 默认为 SFTP 协议)。

    open ftp://username:password@host:port -implicit -certificate="aa:aa:aa:aa..."
    

    详情见:
    https://winscp.net/eng/docs/session_url
    https://winscp.net/eng/docs/scriptcommand_open

    如果这没有帮助,您需要与我们分享一个脚本日志文件或至少一个错误消息。

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 2017-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多