WinSCP “Too many parameters for command 'open&

2020-02-13 05:05发布

问题:

I am trying to connect to an SFTP with the following command to move all .csv files from one location to another and I'm getting the "Too many parameters for command 'open'." error.

option echo off
option batch on
option confirm off
open sftp://XXX@XXX.com/ —hostkey="ssh-rsa 2048 XX:XX:XX:XX:XX:XX:XX" —rawsettings ProxyMethod=3 ProxyHost=proxy.uk.XXX.com
cd /XX/XX/XX/IN/LOAD
lcd \\XX.local\EMEA\XX\XX\Import_Location
put *.csv -nopreservetime=on -nopermissions=on
exit

I added the —hostkey parameter due to the "The server's host key was not found in the cache" error, the batch file was working fine before that, but I want to correct the host key error.

I checked all the dashes, the quotes, the only thing I'm confused about is whether the hostkey parameter is correct. The information online on WinSCP and some forums says you have to use SHA-256 fingerprint of the host key only which is a different format to the MD5 detail XX:XX:XX:XX.... Please can you help which one it is?

—hostkey="ssh-rsa 2048 XX:XX:XX:XX:XX:XX:XX"

OR

—hostkey="ssh-rsa 2056 AbC50IDzyx.....="

This is a similar query to mine, but I cannot see what the difference is so that theirs works and mine doesn't. Thank you.

回答1:

The symbol you have at the beginning of —hostkey and —rawsettings is not a simple hyphen-minus (-), but em-dash ().

Please use hyphen-minus (-) – what is the dash that you find on the standard English [and other] keyboards.

Or even easier, have WinSCP GUI generate a script template for you.


So actually you have the very same problem as in WinSCP forum post you referred to.


Other questions with the same error message, but different problem:

  • WinSCP command line - Too many parameters for command 'open' when using -rawtransfersettings switch
  • Getting "Too many parameters for command", when calling WinSCP command-line from VBA
  • FTP "Too many parameters for command 'synchronize'" with WinSCP


回答2:

Obtaining the correct hostkey fingerprint:

https://winscp.net/eng/docs/faq_hostkey