# Configure SSH private key from kubernetes secret in JCASC plugin?

**URL:** <https://community.jenkins.io/t/configure-ssh-private-key-from-kubernetes-secret-in-jcasc-plugin/463>\
**Category:** Using Jenkins\
**Created:** [October 3, 2021, 4:17pm UTC](https://community.jenkins.io/t/configure-ssh-private-key-from-kubernetes-secret-in-jcasc-plugin/463 "2021-10-03T16:17:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev-samples](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/dev-samples/32/292_2.png) [@dev-samples](https://community.jenkins.io/u/dev-samples)\
**Post date:** [October 3, 2021, 4:17pm UTC](https://community.jenkins.io/t/configure-ssh-private-key-from-kubernetes-secret-in-jcasc-plugin/463/1 "2021-10-03T16:17:37Z")

</div>

Is it possible to specify a kubernetes secret as the source for the private SSH key in JCASC plugin?

I have this:

```auto

      JCasC:
        defaultConfig: true      
        configScripts:
          use-script-security: |
            security:
              globalJobDslSecurityConfiguration:
                useScriptSecurity: false
          welcome-message: |
            jenkins:
              systemMessage: Welcome to our CI\CD server. This Jenkins is configured and managed 'as code'.
          setup-ssh-keys: |
            credentials:
              system:
                domainCredentials:
                  - credentials:
                      - basicSSHUserPrivateKey:
                          scope: GLOBAL
                          id: sample-ssh-key
                          username: git
                          description: "SSH key for remote git"
                          privateKeySource:
                            directEntry:                          
                              privateKey: "ssh-private-key"

```

Where ssh-private-key is:

```auto
$ kubectl -n jenkins get secret ssh-private-key -oyaml
apiVersion: v1
data:
  filename: LS0tL..Qo=
kind: Secret
metadata:
  name: ssh-private-key
  namespace: jenkins
type: Opaque

```

But nothing is created in the jenkins master credentials section.

Also looked at:

> **[configuration-as-code-plugin/demos/credentials at master ·...](https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos/credentials)**
>
> master/demos/credentials

but that does not have an example of using a k8s secret.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [October 3, 2021, 6:55pm UTC](https://community.jenkins.io/t/configure-ssh-private-key-from-kubernetes-secret-in-jcasc-plugin/463/2 "2021-10-03T18:55:35Z")

</div>

if you use the kubernetes secret provider - [https://plugins.jenkins.io/kubernetes-credentials-provider/](https://plugins.jenkins.io/kubernetes-credentials-provider/) then you don’t need to define said secrets again in jcasc.

---

<div class="post-metadata">

**Author:** ![dev-samples](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/dev-samples/32/292_2.png) [@dev-samples](https://community.jenkins.io/u/dev-samples)\
**Post date:** [October 4, 2021, 6:31am UTC](https://community.jenkins.io/t/configure-ssh-private-key-from-kubernetes-secret-in-jcasc-plugin/463/3 "2021-10-04T06:31:42Z")

</div>

Works like a charm, thanks!
