[JIRA] (JENKINS-60714) Cannot create jenkins ssh username with private key credential via rest xml api

2 views
Skip to first unread message

samthesavage@gmail.com (JIRA)

unread,
Jan 9, 2020, 1:24:02 PM1/9/20
to jenkinsc...@googlegroups.com
Sam Savage created an issue
 
Jenkins / Bug JENKINS-60714
Cannot create jenkins ssh username with private key credential via rest xml api
Issue Type: Bug Bug
Assignee: Unassigned
Components: credentials-plugin
Created: 2020-01-09 18:23
Priority: Minor Minor
Reporter: Sam Savage

Basically, I am trying to create a credential on jenkins via Rest API. Using xml data below:

```
<?xml version='1.0' encoding='UTF-8'?>
<com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey>
<scope>GLOBAL</scope>
<id>jenkins-github-ssh</id>
<description>jenkins-github-ssh</description>
<username>username</username>
<directEntryPrivateKeySource>
<privateKey>----BEGIN OPENSSH PRIVATE KEY----
*****************************************
----END OPENSSH PRIVATE KEY----</privateKey>
</directEntryPrivateKeySource>
</com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey>
```

I can see the [credential][1] after calling REST post request. But when I use this credential for a GitHub repository, Jenkins says:

>Failed to connect to repository : Command "git ls-remote -h – g...@github.com:***.git HEAD" returned status code 128:
stdout:
stderr: Load key "/tmp/ssh3978703187838467164.key": invalid format
g...@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

But If I update the credential which is created by rest api with same private key above manually. It works. Somehow key is broken while posting, which seems to be a bug.

 

Do you guys have any idea to point me to a workaround?

Jenkins 2.198 & SSH Credentials Plugin 1.17.3

Thanks

[1]: https://i.stack.imgur.com/j7Ncg.png

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages