powershell and open hostkey switch help please

Advertisement

capt_rob
Guest

powershell and open hostkey switch help please

Hello,

I'm trying to use winscp from powershell to upload a file to an sftp server. What I'm doing works when I run the commands one at a time, but the -hostkey switch seems to get ignored when running the actual script. Can someone please help me understand what I'm doing wrong?


Here's my script:

$starttime = Get-Date
write-output "**** script start $starttime ****"
Set-Location "C:\Program Files (x86)\WinSCP"
.\WinSCP.com /command "option batch continue" "option confirm off" "open USERNAME:PASSWORD@SFTP.SERVER.com -hostkey=""ssh-rsa 2048 b9:ca:61:17:cd:93:76:9f:dd:bb:77:50:84:b5:bd:bc""" "put C:\install\scripts\test.txt" "exit"
$finishtime = Get-Date
write-output "**** script finish $finishtime ****"


And here's the output:

**** script start 10/12/2011 11:27:09 ****
batch continue
confirm off
Searching for host...
Connecting to host...
Authenticating...
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 b9:ca:61:17:cd:93:76:9f:dd:bb:77:50:84:b5:bd:bc
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
Continue connecting and add host key to the cache?
(Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel
Host key wasn't verified!
Authentication failed.
Unknown command '2048'.
Unknown command 'b9:ca:61:17:cd:93:76:9f:dd:bb:77:50:84:b5:bd:bc'.
No session.
**** script finish 10/12/2011 11:27:09 ****



I've tried different options with 'confirm' and 'batch' and I've tried different things with quotes but what I have there I believe to be correct. Any help would really be appreciated.

Many thanks,

Rob

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: powershell and open hostkey switch help please

I do not see anything wrong about your command.
What version of WinSCP are you using? Make sure you use the latest (stable) one.

Reply with quote

Advertisement

You can post new topics in this forum