-1

I have WinSCP script connecting to am SFTP site. It establishes connection and says "starting session" but exits.

This is my script FilePull.txt:

open sftp://***:****@sftp.****.com:22  -hostkey="
ssh-rsa 1024 **********"

which is being called as:

Winscp.exe /console /script="C:\FilePull.txt" /log="C:\winscp.log" /loglevel=0

This is from 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.

It should connect to SFTP site and get the files.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
goodprg
  • 65
  • 4
  • 14

1 Answers1

0

If you really have the open command in two lines, then the problem is obvious.

It should be

open sftp://***:****@sftp.****.com:22  -hostkey="-rsa 1024 **********"

instead of:

open sftp://***:****@sftp.****.com:22  -hostkey="
ssh-rsa 1024 **********"

Additionally, there's nothing in your script, what would make WinSCP "get the files".

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992