Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy Files Over SSH: Cannot parse privateKey: Unsupported key format #8818

Closed
compilenix opened this issue Nov 12, 2018 · 10 comments
Closed
Assignees

Comments

@compilenix
Copy link

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.

@joshmgross
Copy link
Member

@compilenix Are you still dealing with this issue?

@compilenix
Copy link
Author

Yes

@benydc
Copy link

benydc commented Feb 20, 2019

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"

@joshmgross
Copy link
Member

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.

@compilenix
Copy link
Author

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?)

@benydc
Copy link

benydc commented Feb 20, 2019

@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.

@joshmgross
Copy link
Member

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

@jhonalexander0809
Copy link

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.

@FREE-LSD
Copy link

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

@joshmgross
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants