Today I came across a problem while using pSFTP.exe and powershell to automate an ftp process. On new servers the script fails to run because the RSA fingerprint does not get cached and it bombs out. pSFTP does not actually have a flag or option to accept all keys, but we can work around the issue.
Here is the code to fix it:
1 |
echo y | ./psftp sftp.example.com -l username -pw password -b psftpscript.txt |
Note: If using this workaround you cannot issue the -batch command to disable all interactive prompts. There would need to be some logic to detect first run, use the workaround and remove the -batch flag. Then on the second run you could continue using -batch to disable interactive prompts.