Topic "When using -hostkey option in script mode, open command fails with "Too many parameters" error."

Author Message
Guest




I cannot use the -hostkey option with the open command in a script.

When I try like this:

winscp.com /command "open sftp//username/password@ipaddress -hostkey ""ssh-rsa 1536 XX:XX:XX:XX:XX:XX:XX:XX:XX""" "get xxx" exit

I get the following error:

Too many parameters for command 'open'

I get the same error when I tried rearranging and placing the -hostkey option first, like this.

winscp.com /command "open -hostkey ""ssh-rsa 1536 XX:XX:XX:XX:XX:XX:XX:XX:XX"" sftp//username/password@ipaddress" "get xxx" exit

The exact same command like works without the -hostkey value, but only from my interactive session where I have the key stored. However, I need this to work from an automatically scheduled SSIS job, and it always fails to accept the key from the SFTP site since it runs from the SQLServerAGENT user.
Greg S

Guest


In my post, I accidentally omitted the colon (Smile after the sftp in both examples, but the actual script does contain the proper format.

winscp.com /command "open sftp://username/password@ipaddress -hostkey ""ssh-rsa 1536 XX:XX:XX:XX:XX:XX:XX:XX:XX""" "get xxx" exit
winscp.com /command "open -hostkey ""ssh-rsa 1536 XX:XX:XX:XX:XX:XX:XX:XX:XX"" sftp://username/password@ipaddress" "get xxx" exit

Either way it fails with the 'Too many parameters for command 'open'' error.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
The correct syntax is:
winscp.com /command "open sftp//username/password@ipaddress -hostkey=""ssh-rsa 1536 XX:XX:XX:XX:XX:XX:XX:XX:XX""" "get xxx" exit

Note the =

See https://winscp.net/eng/docs/scriptcommand_open#examples
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License