0

I have a Kubernetes pod with a persistent volume mounted at /data. I am trying to use the pod for remote development and as such, need to ensure that my private ssh key persists upon pod restart so I can continue to authenticate to GitHub without generating a new key.

I tried export HOME="/data" and pointing ssh-keygen to /data/.ssh but I was still unable to authenticate to GitHub. Presumably, ssh is not looking at /data/.ssh for my private key. What is the solution here? I do have control over the Dockerfile used for the pod if there is any config there that is necessary.

Harry Stuart
  • 101
  • 1

1 Answers1

1

To keep your private SSH key alive between pod restarts and ensure SSH uses the correct place for the key. You might attempt the following steps.

  1. Include a '/data' directory within the Docker image in your Dockerfile. Then, copy your private SSH key to '/data/.ssh' and provide the key the necessary permissions.

  2. When creating your pod manifest, make sure you include a PersistentVolumeClaim(PVC) to claim the desired persistent volume for '/data'.

  3. Add volume and volume mount definitions to the pod specification to mount the PVC to the '/data' directory.

Follow the docs GitHub with SSH and Setting Up SSH Keys for more information.