Question, Bug, or Feature?
Type: Bug
Enter Task Name: Copy files over SSH
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
My pipline like:
[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_tasksCopyFilesOverSSH_67cec91b-0351-4c2f-8465-d74b3d2a2d96\0.151.1\task.json
2019-09-26T17:24:58.1953150Z ##[debug]set resource file to: d:a_tasksCopyFilesOverSSH_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]
I have similar issue with the task SSH command. need to log with the privatekey option . hope this issue will be resolved soon
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.
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.

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.
Could you share the screenshot where did you disabled 'preview feature "service connection"'?
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.
@epsmae Thx for the tip. I can confirm that disabling The preview feature "service connection" fixed the issue for me.
@epsmae Thanks for the tip! Disabling the preview feature Service connection fixed the issue for me as well.
@epsmae Thanks you.
@epsmae Thanks a lot for your answer.
Disabling the preview feature Service connection fixed the issue for me as well.

Jeeez thanks @epsmae, had the same issue and after testing different types of keys this is what worked for me in the end! 馃憤
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
Could someone from the release side take a look at this, looks like a service connections issue
Most helpful comment
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.