jenkinsci / jenkinsci/ssh-credentials-plugin

[JENKINS-67534] "invalid format" error when pasting SSH private key without armor

Open
#317 3 comments 1 reaction 0 assignees View on GitHub
component:ssh-credentials-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
25
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Pasting a private SSH key in the Jenkins credentials page, and omitting the delimitting comment lines such as: ----- BEGIN OPENSSH PRIVATE KEY ----- causes the key to not work, with an error message such as:

Failed to connect to repository : Command "git ls-remote -h -- ssh://user:@​host:port/project HEAD" returned status code 128:[...]

Load key "/tmp/jenkins-gitclient-ssh14352756356499154328.key": invalid format user@​host: Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rightsand the repository exists.

Repasting the private key with both the top and bottom delimitting lines ----- BEGIN OPENSSH PRIVATE KEY -----, the error vanishes.

I'd expect it to work without these lines which are comments, AFAIK.  If they are somehow necessary, then the tool should fail early, at the time the user input the key text.

---
Originally reported by apteryx3, imported from: "invalid format" error when pasting SSH private key without armor


  • assignee: jvz
  • status: Open
  • priority: Minor
  • component(s): ssh-credentials-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 3
  • imported: 20251215-193512

Raw content of original issue

Pasting a private SSH key in the Jenkins credentials page, and omitting the delimitting comment lines such as: ----- BEGIN OPENSSH PRIVATE KEY ----- causes the key to not work, with an error message such as:



Failed to connect to repository : Command "git ls-remote -h -- ssh://user:@host:port/project HEAD" returned status code 128:[...]

Load key "/tmp/jenkins-gitclient-ssh14352756356499154328.key": invalid format user@host: Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rightsand the repository exists.

Repasting the private key with both the top and bottom delimitting lines ----- BEGIN OPENSSH PRIVATE KEY -----, the error vanishes.

I'd expect it to work without these lines which are comments, AFAIK.  If they are somehow necessary, then the tool should fail early, at the time the user input the key text.

  • environment: Jenkins 2.289.2 with SSH Credentials 1.19 and Git plugin 4.10.1.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.