<p>I have an helm-chart that references sftp key string:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    env:
    - name: PUBLIC_KEY
      value: secretFromVault
    - name: PRIVATE_KEY
      value: secretFromVault
</code></pre>
<p>I have a <code>DockerFile</code> that sets up my user and creates an <code>.ssh</code> directory</p>
<pre><code>RUN adduser -D -s /bin/bash -h /test_user test_user &amp;&amp;\
mkdir /test_user/.ssh/ &amp;&amp;\
chmod 700 /test_usr/.ssh/ &amp;&amp;
</code></pre>
<p>In this directory, I want to create the <code>id_rsa</code> file and input the private key string and create a <code>knownhost</code> file and input the reference of the public key so I can establishing remote connection target server?</p>
<p>How can I do this using dockerfile? Or is there a better way to do this? My sftp client code references these two files.</p>

M06H
<p>Instead of making your secrets as environment variable, you need to mount them as a file.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    volumeMounts:
    - name: keys
      mountPath: /home/test_user/.ssh
      subPath: id_rsa.pub
    - name: keys
      mountPath: /home/test_user/.ssh
      subPath: id_rsa
  volumes:
  - name: keys
    secret:
      secretName: secretFromVault
      defaultMode: 384
</code></pre>
<p>You will need to update the secret name from <code>PUBLIC_KEY</code> and <code>PRIVATE_KEY</code> to <code>id_rsa.pub</code> and <code>id_rsa</code> in this case.</p>
