SSH keypair not working for Jenkins CLI

177 views
Skip to first unread message

Eric Fetzer

unread,
Sep 18, 2015, 12:57:09 PM9/18/15
to Jenkins Users
I am attempting to connect into Jenkins via id_rsa/id_rsa.pub.  My keys are obviously good because I do this all over the place with ssh.  Jenkins-cli.jar seems a bit confused to me.  Please take a look at my output:

$ /cygdrive/c/Java/bin/java -jar jenkins-cli.jar -s http://myserver:8080/ -i /home/efetzer/.ssh/id_rsa who-am-i
No such file exists: \home\efetzer\.ssh\id_rsa
Jenkins CLI
Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...
Options:
-s URL       : the server URL (defaults to the JENKINS_URL env var)
-i KEY       : SSH private key file used for authentication
-p HOST:PORT : HTTP proxy host and port for HTTPS proxy tunneling. See http://jenkins-ci.org/https-proxy-tunnel
-noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution
-noKeyAuth   : dont try to load the SSH authentication private key. Conflicts with -i
The available commands depend on the server. Run the help command to
see the list.

$ ls /home/efetzer/.ssh
id_rsa  id_rsa.pub  known_hosts


It appears as though Jenkins-cli.jar windowafied my directory seperators.  It's true I'm on a winders box, but running in Cygwin.  Any help would be appreciated.

Thanks,
Eric

Victor Martinez

unread,
Sep 18, 2015, 3:08:35 PM9/18/15
to Jenkins Users
Have you tried with the full path where you have your cygwin installation, lets assume your installation is based on /cygdrive/c/cygwin then your full home path should be something like:
/cygdrive/c/cygwin/home/efetzer

Eric Fetzer

unread,
Sep 18, 2015, 3:22:48 PM9/18/15
to Jenkins Users
OK, answering my own question because I've been hammering at it.  The only thing that seems to work is to use a completely relative path:

$ /cygdrive/c/Java/bin/java -jar jenkins-cli.jar -s http://myserver:8080/ -i ../.ssh/id_rsa who-am-i
Authenticated as: efetzer
...

Anyone with a clue as to why?  Maybe this won't be an issue once I move to the Linux box I will be using in the real world...

Eric Fetzer

unread,
Sep 18, 2015, 3:55:33 PM9/18/15
to Jenkins Users
Just tried Victor, no such luck:

$ /cygdrive/c/Java/bin/java -jar jenkins-cli.jar -s http://myserver:8080/ -i /cygdrive/c/CYGWIN/home/efetzer/.ssh/id_rsa who-am-i
No such file exists: \cygdrive\c\CYGWIN\home\efetzer\.ssh\id_rsa

Jenkins CLI
Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...
Options:
-s URL       : the server URL (defaults to the JENKINS_URL env var)
-i KEY       : SSH private key file used for authentication
-p HOST:PORT : HTTP proxy host and port for HTTPS proxy tunneling. See http://jenkins-ci.org/https-proxy-tunnel
-noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution
-noKeyAuth   : dont try to load the SSH authentication private key. Conflicts with -i
The available commands depend on the server. Run the help command to
see the list.

$ ls /cygdrive/c/CYGWIN/home/efetzer/.ssh
id_rsa  id_rsa.pub  known_hosts

Benjamin Lau

unread,
Sep 18, 2015, 3:59:12 PM9/18/15
to Jenkins Users
notice how the directory separator characters are being switched from
/ to \. My guess is that if you used
C:\\cygwin\\home\\efetzer\\.ssh\\id_rsa it might work the way you
expect. The java binary you're using isn't aware of what cygwin is
doing with paths and such so my guess is that it's behaving like any
other windows executable in this context.

Cheers,
Ben
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/437087e6-9157-4706-af26-ca1aab41d379%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Eric Fetzer

unread,
Sep 18, 2015, 4:03:49 PM9/18/15
to Jenkins Users
Ahhh, you got it Ben!  That did it.  Thanks!  Something to note for CYGWIN usage with CLI...
Reply all
Reply to author
Forward
0 new messages