Azure-pipelines-tasks: Copy Files Over SSH: Cannot parse privateKey: Unsupported key format

Created on 12 Nov 2018  路  10Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - Azure Pipelines or TFS on-premises?
    TFS on-premises

    • If using TFS on-premises, provide the version:
      Version 16.122.27409.2
    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number: -
  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name:

    • If using private agent, provide the OS of the machine running the agent and the agent version:
      OS: Ubuntu 16.04.5 LTS
      Agent Version: 2.122.2

Issue Description

Task name: Copy Files Over SSH

The task is not able to parse the ssh private key, provided by the endpoint type "ssh".

I've tried the following commands to generate a rsa key:

ssh-keygen -f id_rsa -t rsa -p -a 100

and

ssh-keygen -f id_rsa -t rsa -o -p -a 100

neither format versions does work.

example key:

-----BEGIN OPENSSH PRIVATE KEY-----
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
********************************************************************
-----END OPENSSH PRIVATE KEY-----

using the key from a linux host to connect to an other host via bash does work.

Task logs

ReleaseLogs_9.zip

Error logs

[error]Failed to connect to remote machine. Verify the SSH endpoint details. Error: Cannot parse privateKey: Unsupported key format.

CrossPlatform

Most helpful comment

It worked when creating a ssh key using this command: ssh-keygen -t rsa -m PEM

Operating System: Ubuntu 16.04.5 LTS
OpenSSH version: 7.2p2

I think this command should be documented somewhere (maybe via this issue?)

All 10 comments

@compilenix Are you still dealing with this issue?

Yes

I have the same exact issue, I can connect fine with the RSA private key to the server but not pipeline "Copy Files Over SSH"

The Copy Files over SSH task uses the SSH2 npm package (https://www.npmjs.com/package/ssh2) for the SSH connections, so it appears that the error is coming from there. The task itself does not do any key parsing.

Based on this stack exchange post it sounds like certain versions of OpenSSH will generate a key in a newer format that is not compatible.

Could you try adding the -m PEM to your keygen and see if that works?

Also see here for more info and another option:
https://serverfault.com/questions/380712/ssh-public-key-format

If that doesn't work, could you tell me your Operating System and OpenSSH version so that I can look into this issue a bit more.

It worked when creating a ssh key using this command: ssh-keygen -t rsa -m PEM

Operating System: Ubuntu 16.04.5 LTS
OpenSSH version: 7.2p2

I think this command should be documented somewhere (maybe via this issue?)

@joshmgross thanks this worked.

I think the Copy Files Over SSH is using an old verion of ssh2 library, the new version has already been updated but from what I saw the Copy Files Over SSH task will have the update this February late or beginning of March. After that I will recreate my keys with OpenSSH mode.

Glad it worked. I've updated the documentation with this workaround.

It worked when creating a ssh key using this command: ssh-keygen -t rsa -m PEM

Operating System: Ubuntu 16.04.5 LTS
OpenSSH version: 7.2p2

I think this command should be documented somewhere (maybe via this issue?)

thanks, Your comment worked for me.

Hi,
I'm experiencing the same issue with the Azure Copy SSH Task,
where do I actually use ssh-keygen -t rsa -m PEM when i'm simply trying to copy over files via SSH?
do I need an additional task for this?

image

馃憢 @SuperDuperOne please open a new issue, this one is closed.

Was this page helpful?
0 / 5 - 0 ratings