Ssh – Add ssh credentials from web interface

Jenkinsssh

I'm currently trying to access a mercurial repository from a Jenkins Job. I've already added the ssh private key trough the Credentials plugin and configured the mercurial plugin to use it.

The error I'm currently getting is remote: Host key verification failed.. After a Google search I've come to the conclusion that the error is caused by the user jenkins not having the host registered in the known_hosts. Is this assumption correct?

Since I have no access to the Jenkins' host machine, how can I fix this issue from the Jenkins web interface?

Best Answer

Yes, it's a missing known_hosts entry. No problem with lack of shell access, you can create a Jenkins job which contains just a "batch" command similar to this:

ssh-keyscan -t rsa my_host | tee -a ~/.ssh/known_hosts

Build this little "project" and ssh shall work beautifully. If you have a larger Jenkins environment with multiple slaves, you need to run this on all slaves.