1

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
byuli
  • 55
  • 2
  • 12

2 Answers2

2

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:

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 2
    Once he said he'd already checked that I didn't bring it up, thought it was only in the example code accidentally, but the more I Think about it the more likely that's the issue. I thought the issue was he didn't know what the hostkey was or how to obtain it, - which was the Q he asked, but I think you are probably right, so thats my upvote ot you. – Ben Personick Dec 09 '19 at 23:14
  • 1
    Oh, so sorry, I've completely misread the forums about dashes. I had the normal hyphens and then changed them all to em-dashes... Thank you, it works now! – byuli Dec 10 '19 at 08:37
0

Obtaining the correct hostkey fingerprint:

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

Ben Personick
  • 3,074
  • 1
  • 22
  • 29