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 #11439

Closed
epsmae opened this issue Sep 26, 2019 · 13 comments
Closed

Copy files over SSH: Cannot parse privateKey #11439

epsmae opened this issue Sep 26, 2019 · 13 comments

Comments

@epsmae
Copy link

epsmae commented Sep 26, 2019

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Copy files over SSH

Environment

  • Server - Azure Pipelines
  • Agent - Hosted

Issue Description

Copy files over SSH does not work with a private key. I am able to connect with username and passwort only but not with a private key. In the error log is visible that "Cannot parse privateKey: Unsupported key format", however I tried multiple versions like:

ssh-keygen -t rsa -b 2048
ssh-keygen -t rsa -m PEM -b 2048
ssh-keygen -t rsa -m PEM

I used powershell version 5.1.18362.145 for the key generation.

I also stumbled over Issue 8818 which is already closed, however the same keygen options do not work for me.

My service connection looks like the following
service_connection

My pipline like:
pipline

Error logs

[2019-09-26T17:24:57.5708149Z ==============================================================================
2019-09-26T17:24:57.5708283Z Task : Copy files over SSH
2019-09-26T17:24:57.5708379Z Description : Copy files or build artifacts to a remote machine over SSH
2019-09-26T17:24:57.5708485Z Version : 0.151.1
2019-09-26T17:24:57.5708570Z Author : Microsoft Corporation
2019-09-26T17:24:57.5708684Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/copy-files-over-ssh
2019-09-26T17:24:57.5708804Z ==============================================================================
2019-09-26T17:24:58.1932243Z ##[debug]agent.workFolder=d:\a
2019-09-26T17:24:58.1938497Z ##[debug]loading inputs and endpoints
2019-09-26T17:24:58.1943022Z ##[debug]loading ENDPOINT_AUTH_93ebd23f-ee98-41a1-8ff1-6361292f2e0d
2019-09-26T17:24:58.1945702Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_93ebd23f-ee98-41a1-8ff1-6361292f2e0d_PASSWORD
2019-09-26T17:24:58.1948155Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_93ebd23f-ee98-41a1-8ff1-6361292f2e0d_USERNAME
2019-09-26T17:24:58.1948949Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2019-09-26T17:24:58.1949268Z ##[debug]loading ENDPOINT_AUTH_SCHEME_93ebd23f-ee98-41a1-8ff1-6361292f2e0d
2019-09-26T17:24:58.1949554Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2019-09-26T17:24:58.1949821Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2019-09-26T17:24:58.1950086Z ##[debug]loading INPUT_CLEANTARGETFOLDER
2019-09-26T17:24:58.1950347Z ##[debug]loading INPUT_CONTENTS
2019-09-26T17:24:58.1950694Z ##[debug]loading INPUT_FAILONEMPTYSOURCE
2019-09-26T17:24:58.1951023Z ##[debug]loading INPUT_FLATTENFOLDERS
2019-09-26T17:24:58.1951287Z ##[debug]loading INPUT_OVERWRITE
2019-09-26T17:24:58.1951549Z ##[debug]loading INPUT_SOURCEFOLDER
2019-09-26T17:24:58.1951803Z ##[debug]loading INPUT_SSHENDPOINT
2019-09-26T17:24:58.1952078Z ##[debug]loading INPUT_TARGETFOLDER
2019-09-26T17:24:58.1952336Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2019-09-26T17:24:58.1952590Z ##[debug]loaded 16
2019-09-26T17:24:58.1952858Z ##[debug]check path : d:\a_tasks\CopyFilesOverSSH_67cec91b-0351-4c2f-8465-d74b3d2a2d96\0.151.1\task.json
2019-09-26T17:24:58.1953150Z ##[debug]set resource file to: d:\a_tasks\CopyFilesOverSSH_67cec91b-0351-4c2f-8465-d74b3d2a2d96\0.151.1\task.json
2019-09-26T17:24:58.1953426Z ##[debug]system.culture=en-US
2019-09-26T17:24:58.1953689Z ##[debug]sshEndpoint=93ebd23f-ee98-41a1-8ff1-6361292f2e0d
2019-09-26T17:24:58.1954066Z ##[debug]93ebd23f-ee98-41a1-8ff1-6361292f2e0d auth param username = ***
2019-09-26T17:24:58.1954687Z ##[debug]93ebd23f-ee98-41a1-8ff1-6361292f2e0d auth param password = ***
2019-09-26T17:24:58.1954886Z ##[debug]93ebd23f-ee98-41a1-8ff1-6361292f2e0d data host = my-server.com
2019-09-26T17:24:58.1955061Z ##[debug]93ebd23f-ee98-41a1-8ff1-6361292f2e0d data port = 22
2019-09-26T17:24:58.1955410Z ##[debug]Using private key for ssh connection.
2019-09-26T17:24:58.1955673Z ##[debug]contents=**
2019-09-26T17:24:58.1956288Z ##[debug]sourceFolder=d:\a\1\s\scripts\doc
2019-09-26T17:24:58.1956713Z ##[debug]check path : d:\a\1\s\scripts\doc
2019-09-26T17:24:58.1956988Z ##[debug]targetFolder=/home/test
2019-09-26T17:24:58.1957249Z ##[debug]cleanTargetFolder=true
2019-09-26T17:24:58.1957507Z ##[debug]overwrite=true
2019-09-26T17:24:58.1957758Z ##[debug]failOnEmptySource=true
2019-09-26T17:24:58.1958055Z ##[debug]flattenFolders=false
2019-09-26T17:24:58.1958285Z Setting up SSH service connection to remote host my-server.com.
2019-09-26T17:24:58.1958555Z ##[debug]task result: Failed
2019-09-26T17:24:58.2015161Z ##[error]Error: Failed to connect to remote machine. Verify the SSH service connection details. Error: Cannot parse privateKey: Unsupported key format.
2019-09-26T17:24:58.2025471Z ##[debug]Processed: ##vso[task.issue type=error;]Error: Failed to connect to remote machine. Verify the SSH service connection details. Error: Cannot parse privateKey: Unsupported key format.
2019-09-26T17:24:58.2042179Z ##[debug]Processed: ##vso[task.complete result=Failed;]Error: Failed to connect to remote machine. Verify the SSH service connection details. Error: Cannot parse privateKey: Unsupported key format.
2019-09-26T17:24:58.2042504Z ##[debug]Closing the client connection
2019-09-26T17:24:58.2071986Z ##[section]Finishing: CopyFilesOverSSH]

@birko
Copy link

birko commented Oct 1, 2019

I have similar issue with the task SSH command. need to log with the privatekey option . hope this issue will be resolved soon

@rchmielowiec
Copy link

rchmielowiec commented Oct 18, 2019

I have the same issue. Key was working on self hosted TFS server, on cloud Azure DevOps server its not working with "Error: Cannot parse privateKey: Unsupported key format". Installed locally Azure Devops Server on my machine to test it locally and its working. The only difference i've found so far is that on local Azure Devops server version of extension visible in the logs is 0.142.2 on cloud version of Azure Devops it's 0.151.1. On older TFS server it's 0.121.0. Keys generated on powershell in windows and bash on centos. Also tried with -m PEM option. Always the same error.

@epsmae
Copy link
Author

epsmae commented Oct 20, 2019

I finally found a workaround:
The preview feature "service connection" has to be disabled. Without the preview feature enabled there is a button "Upload SSH private key file...". The same key files as before works perfect.

grafik

@rchmielowiec
Copy link

I finally found a workaround:
The preview feature "service connection" has to be disabled. Without the preview feature enabled there is a button "Upload SSH private key file...". The same key files as before works perfect.

grafik

Could you share the screenshot where did you disabled 'preview feature "service connection"'?

@epsmae
Copy link
Author

epsmae commented Oct 24, 2019

Official there is this manual:
https://docs.microsoft.com/en-us/azure/devops/project/navigation/preview-features?view=azure-devops

For me it looks a bit different:
Click right top on your name then press the "..." behind azure devops profile and then select preview features.

@rchmielowiec
Copy link

@epsmae Thx for the tip. I can confirm that disabling The preview feature "service connection" fixed the issue for me.

@avdbrink
Copy link

@epsmae Thanks for the tip! Disabling the preview feature Service connection fixed the issue for me as well.

@d0972058277
Copy link

@epsmae Thanks you.

@SadokLadhari
Copy link

@epsmae Thanks a lot for your answer.
Disabling the preview feature Service connection fixed the issue for me as well.
image

@nachoizquierdo
Copy link

Jeeez thanks @epsmae, had the same issue and after testing different types of keys this is what worked for me in the end! 👍

@netdragonboberb
Copy link

It would be really nice if the new connection experience (and old upload) did some validation. It's non-obvious that we have to include PEM.

Anyway, I got 4096 keys to work, using:
ssh-keygen -t rsa -m PEM -b 4096

@damccorm
Copy link

Could someone from the release side take a look at this, looks like a service connections issue

@github-actions
Copy link

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

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

15 participants