"Invalid Private key file" error in Open secure FTP connection action

This article provides a resolution to solve the error that occurs when you use a private key file that isn't using OpenSSH format in the "Open secure FTP connection" action in Microsoft Power Automate for desktop.

Applies to:   Power Automate
Original KB number:   5003728

Symptoms

In Microsoft Power Automate for desktop, when you use a private key file as an authentication method in the "Open secure FTP connection" action, you may receive the following error message:

Error message: "Can't connect to ServerHost".
More error details: "Robin.Core.ActionException: Can't connect to ServerHost ---> Renci.SshNet.Common.SshException: Invalid private key file".

Here ServerHost is the FTP server host address used in the action.

Cause

This error can occur if the format of the private key file isn't using OpenSSH format. Power Automate for desktop explicitly checks that the private key file format is OpenSSH, where the key should start with:

---- BEGIN ___ PRIVATE KEY ----

Resolution

To correct the private key file format (OpenSSH Format), make sure that the text in the file looks similar to the following:

----BEGIN ___ PRIVATE KEY----

.............................

.............................

----END ___ PRIVATE KEY----

You can also use PuTTY Key Generator (PuttyGen.exe) to convert the key file to the OpenSSH format. To do that:

  1. Load your existing private key file in PuTTY Key Generator.
  2. Select Conversions > Export OpenSSH key (not the force new file format option).