Vault ssh username with private key jenkins

Hello everyone

I want to integrate Jenkins with Gitlab.

I already integrated Vault and Jenkins and used it with Vault Username-Password Credential and now want to use the vault ssh username with private key type.

Here are my steps:

  1. I generate private and public keys
  2. Store the Public key on the GitLab itself
  3. I want to Store the private key on Vault
  4. Create the vault ssh username with private key credential and use it to connect to Gitlab (Instead of the old ssh username with private key)

How can I implement this step 3?

P.S: I googled, and I didn’t find anything

There is no mention of this credential type on https://plugins.jenkins.io/hashicorp-vault-plugin/ so perhaps it is undocumented / unsupported / incomplete functionality in the Jenkins plugin?

If no-one has documented what configuration on the Vault side is expected for this feature of the Jenkins plugin, it might be that you have to track down the relevant source code and reverse engineer what it expects, or open a bug with the https://plugins.jenkins.io/hashicorp-vault-plugin/ project about this documentation gap.

1 Like

Thank you for tour reply, I guess you’re right.
Because I found absolutly nothing on the Internet…

I had a similar need and came across this thread while searching how to do it. At this time I also did not find a straight-forward guide on the vault ssh username with private key credential type; however, it’s actually pretty easy. Assuming you have the jenkins vault plugin all set up, you just need to create a key value secret in vault and give it the keys and values the credential type asks for: username, key, passphrase. Create the secret in vault with these three k/v pairs then create the credential in jenkins, pointing it to the path and key names you used. If your ssh key does not have a passphrase, you still need to create a passphrase key value pair, leaving the value blank, otherwise jenkins will fail to use the key.