using pscp.exe in a batch file and getting around the host key

I was trying to automate an scp file copy for work and having a hell of a time with the host key. Even though I was logged in as the same user that the script is running, when it’s run non interactive, for some reason it cannot find the host key in the registry, and fails. Some info.

  • putty and  pscp.exe keep their host keys in – [HKEY_CURRENT_USERSoftwareSimonTathamPuTTYSshHostKeys]
  • if you run your pscp.exe with the –batch command, you cannot input any console input
  • in order to get this to work, I had to echo a “Y” to it like thisecho y | C:_scriptspscp -sftp –v  -etc. etc

Basically, If you try to echo the Y with the –batch option, then you can’t because the –batch option makes it ignore any input. In order to make this secure, I ran it once the way I have listed above, and once the host key was stored in the right place, I removed the echo and added the batch again.

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s