Accepting pSFTP.exe host server key/fingerprint automatically – Powershell

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 error:
pserror

Here is the code to fix it:

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.

1 comment… add one
  • John

    Thanks for posting. Removing the -batch resolved this issue for me.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.