I am trying to run groovysh on my Jenkins from the cli, using the following command:
java -jar jenkins-cli.jar -s <Jenkins URL> -i JenkinsPrivateKey.ppk groovysh
I generated this private key file using PuttyGen, and pasted the public key into the SHH Public Keys box on the /me/configure page of the Jenkins. It's not that the key doesn't work - it seems like it's not authenticating at all. When I run who-am-i using the cli:
java -jar jenkins-cli.jar -s <Jenkins URL> -i JenkinsPrivateKey.ppk who-am-i
It gives me a response of:
Authenticated as: anonymous
What am I missing here? I thought if the authentication failed it would at least display an error message of some kind. Is there any way to verify that the private key actually works?
Edit: After some experimentation, it seems that authentication via the CLI does fail silently - I put a bogus public key in my profile configuration, and I still saw no error.Answer1:
You may need to convert your putty keys to openssh format for them to work properly with the key.
See <a href="https://wiki.cloudbees.com/bin/view/DEV/Customer%2BProvided%2BSlaves%2BWindows" rel="nofollow">https://wiki.cloudbees.com/bin/view/DEV/Customer%2BProvided%2BSlaves%2BWindows</a>
"Back to Putty Key Generator, use Conversions > Export OpenSSH key to save the private key to a file."
If that works, feel free to edit <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI" rel="nofollow">the Jenkins CLI wiki page</a>!