Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Respond y(es) to psftp host key prompt

I am creating a script file programmatically and call psftp.exe as follows:

psftp [email protected] -pw password -b psftpscript.txt

but it prompts for user input

The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: [ssh-rsa 1024 somekey] If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n)

I need it to be completely prompt free, automatic. I tried -batch parameter but it just abandons the connection

like image 540
GaneshT Avatar asked Sep 27 '11 23:09

GaneshT


People also ask

What is Psftp command?

PSFTP allows you to run an interactive file transfer session, much like the Windows ftp program. You can list the contents of directories, browse around the file system, issue multiple get and put commands, and eventually log out.

How do I open Psftp in PuTTY?

Below are three ways to open PSFTP: Click on the Windows Start button and go to 'All Programs. ' From the list of program, Click on PuTTY and then PSFTP. The second option is to enter the following path in the address bar – “C:\Program Files (x86)\PuTTY” and then double-click on psftp.exe.

What is host key in PuTTY?

PuTTY records the host key for each server you connect to, in the Windows Registry. Every time you connect to a server, it checks that the host key presented by the server is the same host key as it was the last time you connected.


1 Answers

I had the same problem with running a unattended script in Windows Server 2008's 'sandbox' like environment. I ended up running the following which enters the y at the prompt for you:

echo y | psftp [email protected] -l username -pw password -b psftpscript.txt

Hope this helps!

Note: I only had to run the echo y once and removing it for the 2nd run didn't ask for the key to be cached anymore.

like image 133
vmitchell85 Avatar answered Sep 21 '22 18:09

vmitchell85