Cannot be authenticated with jenkins-cli

Issue

  • I am not able to be authenticated in Jenkins through jenkins-cli
  • I am getting Failed to authenticate with your SSH keys.

Environment

  • CloudBees Jenkins Enterprise
  • jenkins-cli

Resolution

Failed to authenticate with your SSH keys.

suggests that the public key was not added into the user’s account (http:///user//configure), and/or did not pass the private key to the CLI command (using -i). Also, ensure that you are not specifying the username as this is not required for SSH.

See https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI

1.419 and later
If your Jenkins requires authentication, you should set up public key authentication. Login from the web UI and go to http://yourserver.com/me/configure, then set your public keys in the designated text area. When connecting to the server, the CLI will look for ~/.ssh/identity, ~/.ssh/id_dsa, ~/.ssh/id_rsa and use those to authenticate itself against the server. Alternatively, the -i option can be used to explicitly specify the location of the private key.

See the middle of this guide for how to generate SSH key pair, if you don't have one yet.

If you have used PuttyGen to generate your keys, you will have to convert them to openssh format. Otherwise Jenkins might silently ignore your keys and you will be Authenticated as: anonymous.

To use the -i option the syntax is as follows:

java -jar jenkins-cli.jar [-s JENKINS_URL] [-i PRIVATE_KEY] command [options...] [arguments...]
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.