Ssh – Can’t ssh into the node

Jenkinsssh

first, I'm doing this for past two days, but nothing works.

I've seen many tutorials, but no one works for me.

I have jenkins installed, in it I have Master node and I want to create new node. (some agent)

I want to establish connection with ssh.

I have jenkins user already on my new node and generated ssh key.
(where is jenkins installed, there isn't jenkins user).

But the jenkins is telling me 'can't find known_hosts in /var/jenkins_home'. But this file exist.
I checked if port 22 is open on my new node, and yes, it is, I can connect to it from my local PC.

Is there some other method, but it should be with SSH, not agent.rar.

What should I check?

EDIT:

-rw-r--r-- 1 root root 0 Oct 24 17:36 /var/lib/jenkins/.ssh

sudo -u jenkins ssh jenkins@*IP* ls -la .ssh
The authenticity of host '*IP* (*IP*)' can't be established.
ECDSA key fingerprint is SHA256:*FINGERPRINT*.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/var/lib/jenkins/.ssh/known_hosts).
Permission denied (publickey).

Best Answer

You normally have the .ssh directory file permissions set as 700 and owned by the user who needs to access it.

As it is with 644 it's not going to be traversable by anyone (except root) so no wonder it can't be read by a user process. Change the ownership to jenkins and the perms to 700. Then set the ownership/permissions on the contents of the directory correctly too.

Then read up on Unix file and ownership permissions.

Related Topic