Node Connection Error

Hello @seh640 and welcome to this community :wave:

Most of the time I add a jenkins user on the machine I want to use as a node, and then copy an SSH key so that I can easily connect to it through the controller later on.
I also create a link (bad, bad habit) from /home/jenkins to /var/lib/jenkins so /var/lib/jenkins/.ssh/known_hosts does exist. :thinking:
Your error makes me wonder if there’s a better (and official way) to configure a machine in order to make it a node.
Anyway… If you don’t want to change your process and use your existing folder, you could follow the steps below to create the know_hosts file:

  1. Log in to the remote node machine as a user who has sudo access.
  2. Create the directory /var/lib/jenkins/.ssh if it does not exist already: sudo mkdir -p /var/lib/jenkins/.ssh
  3. Set the correct permissions for the directory: sudo chown -R jenkins:jenkins /var/lib/jenkins/.ssh
  4. Create an empty known_hosts file: sudo touch /var/lib/jenkins/.ssh/known_hosts
  5. Set the correct permissions for the known_hosts file: sudo chmod 600 /var/lib/jenkins/.ssh/known_hosts
  6. Add the SSH host keys for your remote hosts to the known_hosts file. You can do this manually by using the ssh-keyscan command:
ssh-keyscan your-remote-hostname >> /var/lib/jenkins/.ssh/known_hosts

Replace your-remote-hostname with the hostname or IP address of your remote host.

After these steps, you should be able to connect to your node through SSH without the “No Known Hosts file was found” error.