Jenkins connect with Git from Controlleer node but not with Agent node (Permission denied (publickey))

Viewed 21

Below is the error when we run the job from agent nodes in jenkins, it works fine when we run the same job on controller.

ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress git@github.com:xxxxxxxxx/xxxxxxxxxxxx.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ubuntu@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
  1. Tried : added ssh to git
  2. slave node configured to git username and keys

Anyone have any clue , why the agent node is not connected with git

1 Answers

Try with:

  • a private key created without passphrase (that way, you don't need an SSH agent)
  • said private key registered in the credentials, using the Jenkins SSH Credentials Plugin

Make sure to select that credentials when using your SSH Git URL in the Jenkins pipeline definition.

Related