我有WinSCP脚本连接到SFTP站点。它建立连接并说“开始会话”,但退出。
这是我的脚本FilePull.txt
:
open sftp://***:****@sftp.****.com:22 -hostkey="
ssh-rsa 1024 **********"
被称为:
Winscp.exe /console /script="C:\FilePull.txt" /log="C:\winscp.log" /loglevel=0
这来自winscp.log
:
. 2019-05-04 18:27:28.626 Started a shell/command
. 2019-05-04 18:27:28.626 --------------------------------------------------------------------------
. 2019-05-04 18:27:28.626 Using SFTP protocol.
. 2019-05-04 18:27:28.626 Doing startup conversation with host.
> 2019-05-04 18:27:28.626 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2019-05-04 18:27:28.739 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2019-05-04 18:27:28.739 SFTP version 3 negotiated.
. 2019-05-04 18:27:28.739 We believe the server has signed timestamps bug
. 2019-05-04 18:27:28.739 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
. 2019-05-04 18:27:28.739 Getting current directory name.
. 2019-05-04 18:27:28.739 Getting real path for '.'
> 2019-05-04 18:27:28.739 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2019-05-04 18:27:28.771 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2019-05-04 18:27:28.771 Real path is '/'
. 2019-05-04 18:27:28.771 Startup conversation with host finished.
< 2019-05-04 18:27:28.771 Script: Active session: [1] vendor-pip@sftp.rcnlv.com
> 2019-05-04 18:27:28.771 Script: ssh-rsa 1024 d9:4a:5d:aa:88:4b:7d:b0:62:33:f8:7a:aa:21:c2:33
< 2019-05-04 18:27:28.772 Script: ssh-rsa 1024 d9:4a:5d:aa:88:4b:7d:b0:62:33:f8:7a:aa:21:c2:33
< 2019-05-04 18:27:28.772 Script: Unknown command 'ssh-rsa'.
. 2019-05-04 18:27:28.772 Script: Failed
. 2019-05-04 18:27:28.772 Script: Exit code: 1
. 2019-05-04 18:27:28.772 Closing connection.
它应该连接到SFTP站点并获取文件。
答案 0 :(得分:0)
如果您确实有两行open
命令,那么问题很明显。
应该是
open sftp://***:****@sftp.****.com:22 -hostkey="-rsa 1024 **********"
代替:
open sftp://***:****@sftp.****.com:22 -hostkey="
ssh-rsa 1024 **********"
此外,您的脚本中没有任何内容,这会使WinSCP “获取文件” 。