Command line use of HostKey

Advertisement

mrdobalina
Joined:
Posts:
3
Location:
USA

Command line use of HostKey

I am using WinSCP in an SSIS execute process task. The input into the executable is variable so I must execute command line. The process will be run from a system account so I need to pass the hostkey. When I run the script without the hostkey specified, under my account which has accepted the hostkey, it executes successfully. Could you please provide some guidance for my syntax?

Here is the command line:
winscp.exe /command  "open ""sftp://uid:password@server:22"" -hostkey ""ssh-rsa 1024 00:00:00:00:00:00:00:00:00:00:aa:bb:cc:dd:ee:ff""" "option batch on"  "option confirm off"  "put ""c:\temp\source\testfile.txt"""  "close"  "exit"
After running the script I get following in console:
Too many parameters for command "open".
batch on
confirm off
no session
no session
Using WinSCP 4.2.4 (Build 610) on Windows XP.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Command line use of HostKey

I do not see anything wrong about your syntax. But I'm not sure if SSIS does parse/interpret the command line on its own somehow. Try to store your script into file instead. Let us know.

Reply with quote

mrdobalina
Joined:
Posts:
3
Location:
USA

Re: Command line use of HostKey

I changed over to a script file with the same results.

My script file contains:
open sftp://testuid:password@server:22 -hostkey "ssh-rsa 1024 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
option batch on
option confirm off
put c:\temp\source\testfile.txt
close
exit

Results:
Too many parameters for command 'open'.
batch on
confirm off
No Session.
No Session.

Works like a charm without the hostkey switch.

One critical piece of information I missed due to sleep deprivation. I've moved development over to a 64 bit server so my environment is:
Windows Server 2003 R2
Standard x64 Edition
Service Pack 2

Reply with quote

martin
Site Admin
martin avatar

Re: Command line use of HostKey

OK, now I have noticed the problem. You miss equal sign between -hostkey and the value:
-hostkey="ssh-rsa 1024 00:00:00:00:00:00:00...."

Reply with quote

Guest

Re: Command line use of HostKey

Thank you for your quick responses. That fixes the issue when I use a script file. Unfortunately, my data will be variable so I must run this from command line instead of dropping script files. Is the syntax slightly different in command? I tried several combinations of quotes, dashes, and slashes.

The script that works successfully:
open sftp://testuid:password@server:22 -hostkey="ssh-rsa 1024 00:00:00:00:00:00:00..."
option batch on
option confirm off
put c:\temp\source\testfile.txt
close
exit

This is the command line that errors:
C:\Program Files (x86)\WinSCP>winscp.com /command "open ftp://testuid:password@server:22 -hostkey=""ssh-rsa 1024 00:00:00:...""" "option batch on" "option confirm off" "put ""c:\temp\source\testfile.txt""" "close" "exit"

Result of this command is:
Too many parameters for command 'open'.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Command line use of HostKey

Your syntax works for me. Though it does not work with releases prior to 4.2.4 with the same error message you are getting. Are you sure you have 4.2.4? Both .com and .exe? Try to reinstall (and of course upgrade to stable 4.2.5).

Reply with quote

Advertisement

You can post new topics in this forum