nishat
nishat

Reputation: 967

Jenkins slave node is offline : Authentication failed

My jenkins slave node is offline. The log is as follows:

[06/11/15 09:02:52] [SSH] Opening SSH connection to <ip>.
ERROR: Server rejected the 1 private key(s) for jenkins (credentialId:d7a17c00-1300-4cf3-8cf5-810b3297ebc6/method:publickey)
[06/11/15 09:02:52] [SSH] Authentication failed.
hudson.AbortException: Authentication failed.
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1178)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:701)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[06/11/15 09:02:52] Launch failed - cleaning up connection
[06/11/15 09:02:52] [SSH] Connection closed.   

I have verified below:

  1. Authorized_keys file at /var/lib/jenkins-slave/.ssh has correct public key of master.
  2. Authorized_keys file at /var/lib/jenkins/.ssh has correct public key of master.
  3. Master has its private and public key files at /var/lib/jenkins/.ssh folder and also at ~/.ssh folder.

I also tried "ssh -i .ssh/id_rsa -l jenkins ” from master machine but it is asking for password. Looks like it is not identifying slave machine.

There is known_hosts file in .ssh folder of both master and slave machine. What data goes in there?

How to resolve the issue?

Upvotes: 2

Views: 18127

Answers (2)

Kasey Chakos
Kasey Chakos

Reputation: 155

SSH Build Agents Plugin Update

Plugin version 2.854.v7fd446b_337c9 requires PEM format

  1. Generate keys on jenkins

    ssh-keygen -t rsa -m PEM

  2. Copy PUBLIC key to Agent authorized_keys (~/.ssh/authorized_keys)

  3. Copy PUBLIC key to Jenkins credentials

Upvotes: 3

Trond
Trond

Reputation: 221

I have just been gone through this pain recently.

What I found out is that you have to make sure the .ssh directory has 700 permissions, and that jenkins has read and the id_rsa.pub should have 644 (not 755 as previously recommended, that would make the file executable, which shouldn't be required).

Also I found that if you have a Windows based slave in there you have to make sure you create your keys without a passphrase.

Upvotes: 2

Related Questions