Question

I'm using WinSCP to transfer some files over to another system, but I'm running into some of problems. Since I was going to use this C# program on various devices the Keys are not the same, so I would like to print out a message box or something similar to the user giving them the option that you would normally see through WinSCP.com:

winscp> (U)pdate,(A)dd,Can(n)cel,(C)opy Key,(S)kip: Cancel

Right now I'm displaying the options to the user with winscp.StandardOutput.ReadLine() and giving them a choice what the return with winscp.StandardInput.WriteLine([user choice]) but this dosn't seem to work. I keep getting "Host Key Wasn't Verified!". Any suggestions on how to approach this one? Thanks.

Edit: I believe this has something to do with WinSCP not waiting for input. I changed the echo option to 'on' so I could see my response and my response occures after WinSCP has already rejected the connection.

My options on WinSCP are currently: batch abort, confirm on, echo on.

So now I guess is there anyway for WinSCP to wait for my commands from the .exe?

Was it helpful?

Solution

So far I've got it working via a "psudo" first connection. I know it's not very pretty and people will (and probably should) scream at me for doing it this way. First off I make an attempted connection to the end device,

winscp.StandardInput.WriteLine(open scp://name:pass@xx.xx.xx.xx);

But that's just to get the key from the end device since I can scan the outputs from winscp and find a message that happens to show that lovely key. So then, now knowing my device's RSA key I can then prompt the user: 'You're CPU dosn't know this device... Connect anyways?' [yes/no/cancel]. If they say yes then I can explicitly give winscp the hostkey I'm looking for and connect,

winscp.StandardInput.WriteLine(open scp://name:pass@xx.xx.xx.xx -hostkey: *****);

Like I said it's not the prettiest, and I'd like to do it with a single connection attempt. But whatever gets the job done right? I'm still looking into this for a better option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top