Search code examples
kubernetesscpkubernetes-cronjob

How to make kubernetes cronjob to identify ssh key from a folder


I have create cron job in kubernetes and I have ssh key in one of pod directory. when I am executing from command line its working fine, but when I am manually triggered , cron job is not recognizing .ssh folder .

scp -i  /srv/batch/source/.ssh/id_rsa   user@server:/home/data/openings.csv  /srv/batch/source

enter image description here


Solution

  • When you log into a remote host from your container, the remote host key is unknown to your SSH client inside the container

    usually, you're asked to confirm its fingerprint:

    The authenticity of host ***** can't be established.
    RSA key fingerprint is *****.
    Are you sure you want to continue connecting (yes/no)?
    

    But as there is no interactive shell, the SSH client fails.

    Two solutions:

    • add the host key in the file ~/.ssh/known_hosts in the container
    • disable host key check (Dangerous as no remote host authentication is performed)

      ssh -o "StrictHostKeyChecking=no" user@host