'Can't connect to Jenkins Slave No Known Hosts file was found at /var/jenkins_home/.ssh/known_hosts
Error message:
/var/jenkins_home/.ssh/known_hosts [SSH] No Known Hosts file was found at /var/jenkins_home/.ssh/known_hosts. Please ensure one is created at this path and that Jenkins can read it.
No matter how much I tried it doesn't work. I've read this post, but still no solution.
Solution 1:[1]
I got the same error while launching slave.It has to do with the SSH Slave Plugin. What worked for me was changing the Host key verification strategy in LAUNCH METHOD from "Known Hosts file verification strategy" to "Manually trusted key verification strategy".
CONFIGURE AGENT -> LAUNCH METHOD -> Manually trusted key verification strategy - > SAVE.
Hope this helps.
Solution 2:[2]
The problem is that Jenkins causes confusion by reporting that the file is missing under /var/jenkins_home/, which is a hard-coded value. Instead, it should be telling you that the file is missing under your actual $JENKINS_HOME path. That way, you would immediately know where to look.
So the easiest way to fix this is to:
Go to the actual
$JENKINS_HOMEdirectory on your Jenkins master, and create a.sshdirectory andknown_hostsfile under it, for example:$ mkdir $JENKINS_HOME/.ssh $ touch $JENKINS_HOME/.ssh/known_hostsIf you've ever SSH-ed from Jenkins master to your slave machine before, then you should already have a
known_hostsfile under your~/.sshdirectory. If you don't, then SSH from Jenkins master to Jenkins slave machine and it will get automatically created for you under~/.sshdirectory for that user.Now open that
~/.ssh/known_hostsfile and simply copy>paste the line that contains your slave machine's IP address to the$JENKINS_HOME/.ssh/known_hostsfile. Alternative way is to copy the entire~/.ssh/known_hostsfile to$JENKINS_HOME/.sshdirectory if that is easier for you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Athul Nath |
| Solution 2 | Goran Vasic |


