Public Key Authentication in Jenkins CLI

Written by: Kohsuke Kawaguchi
2 min read

In Jenkins, the security mechanism is completely pluggable (see my earlier webinar for more details.) While this is good thing, it does make my life difficult in several places. One of them is to authenticate users with Jenkins CLI.

For those of you who haven't heard of Jenkins CLI , it is yet another mechanism to non-interactively access Jenkins from a remote machine and perform a bunch of useful operations, such as create a job, start a build, etc.

Jenkins is primarily a web app, so some of its authentication mechanisms revolves around web protocols that are just plain impossible for authenticating CLI clients (think OpenID and OAuth.) So up until now, support for authentication in Jenkins CLI was limited to those security realm that uses username and password.

This is where one of the fruits of the JAX San Jose Jenkins hackathon comes into play.

Starting 1.419 (which will be out July 4th), Jenkins CLI supports authentication based on the SSH key pair. Just like CloudBees DEV@cloud (or GitHub, or other similar sites), you interactively login from the web UI, then associate your public keys with your user account. Then CLI will silently authenticates itself using your ~/.ssh/id_rsa , ~/.ssh/id_dsa , or ~/.ssh/identity .

Aside from the fact that this is completely independent of the authentication mechanism currently employed on your Jenkins, what I really like about this is that in many places you already use SSH public key to access Git, Subversion, or doing deployment. So it nicely takes advantages of your existing investment, and "it just works."

See the Wiki page about Jenkins CLI for more details, and I hope you like this.

Kohsuke Kawaguchi

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.