I am trying to establish SSH
authentication between Jenkins and GitHub. For the same, I am using the kubernetes secret to store the private and public key and I am mounting the secrets when the pod is created. Command I have used to create the secret:
kubectl create secret generic test-ssh --from-file=id_rsa=id_rsa --from-file=id_rsa.pub=id_rsa.pub --namespace jenkins
and mapped it in pod configuration as:
volumes:
- secretVolume:
mountPath: "/root/.ssh"
secretName: "test-ssh"
When the pod is created, I can see that the secret is mapped correctly in the ~/.ssh
folder as shown below.
but the problem is the ~/.ssh
folder itself has the sticky bit permission enabled
and this is preventing the builds adding the known_hosts
file when ssh-keyscan
command is executed
ssh-keyscan github.com >> ~/.ssh/known_hosts
bash: ~/.ssh/known_hosts: Read-only file system
I was hoping to achieve one of the two solutions I can think of
- Remove the sticky permissions from
~/.ssh
folder after it is created - While mounting the kubernetes secret, mount it without sticky permissions
Could anyone help me to understand if there is a possibility to achieve this?
I have already tried chmod -t .ssh
and it gives me the same error chmod: changing permissions of '.ssh': Read-only file system
The owner of the ~/.ssh
folder is root
and I have logged in as root
user. I have confirmed this by running the whoami
command.