Adding ssh keyfile in gerrit trigger giving error on linux

3,706 views
Skip to first unread message

mani chandel

unread,
Oct 14, 2013, 8:30:51 AM10/14/13
to repo-d...@googlegroups.com
Hi All,

I have installed gerrit and jenkins on linux.
I have installed gerrit trgger plugin on jenkins.
Now I am trying to add the ssh key file to trigger but it is giving me error "/home/mani/.ssh/id_rsa" does not exist. and Bad SSH keyfile or password.

However, this location and file both are existing.
Please help.

Regards,
Mani

Saša Živkov

unread,
Oct 14, 2013, 8:49:22 AM10/14/13
to mani chandel, repo-d...@googlegroups.com
Is this file readable by the user that owns the Jenkins process?

Please help.

Regards,
Mani

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

mani chandel

unread,
Oct 14, 2013, 8:55:37 AM10/14/13
to repo-d...@googlegroups.com, mani chandel
Hi zivkov,

I have given all the permissions 777 to this folder .ssh and all files inside it  i.e id_rsa, id_rsa.pub.

regards,
Mani

mani chandel

unread,
Oct 14, 2013, 9:31:48 AM10/14/13
to repo-d...@googlegroups.com

mani chandel

unread,
Oct 14, 2013, 9:31:59 AM10/14/13
to repo-d...@googlegroups.com
Hi Zivkov,
I checked the jenkins log and saw below error.
I have given all permissions to .ssh folder and all files in it.
Still getting below error.
Please suggest.

Oct 14, 2013 9:18:43 AM SEVERE com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler connect
Could not connect to Gerrit server! Host: localhost Port: 29418
Oct 14, 2013 9:18:43 AM SEVERE com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler connect
 Proxy: 
Oct 14, 2013 9:18:43 AM SEVERE com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler connect
 User: gerrit_developer KeyFile: /home/mani/.ssh/id_rsa
Oct 14, 2013 9:18:43 AM SEVERE com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler connect
IOException: 
com.sonyericsson.hudson.plugins.gerrit.gerritevents.ssh.SshException: com.jcraft.jsch.JSchException: java.io.FileNotFoundException: /home/mani/.ssh/id_rsa (Permission denied)
	at com.sonyericsson.hudson.plugins.gerrit.gerritevents.ssh.SshConnectionImpl.(SshConnectionImpl.java:126)
	at com.sonyericsson.hudson.plugins.gerrit.gerritevents.ssh.SshConnectionFactory.getConnection(SshConnectionFactory.java:76)
	at com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler.connect(GerritHandler.java:401)
	at com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler.run(GerritHandler.java:312)
Caused by: com.jcraft.jsch.JSchException: java.io.FileNotFoundException: /home/mani/.ssh/id_rsa (Permission denied)
	at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:98)
	at com.jcraft.jsch.JSch.addIdentity(JSch.java:224)
	at com.jcraft.jsch.JSch.addIdentity(JSch.java:218)
	at com.sonyericsson.hudson.plugins.gerrit.gerritevents.ssh.SshConnectionImpl.(SshConnectionImpl.java:99)
	... 3 more
Caused by: java.io.FileNotFoundException: /home/mani/.ssh/id_rsa (Permission denied)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.(FileInputStream.java:146)
	at java.io.FileInputStream.(FileInputStream.java:101)
	at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:83)
	... 6 more


Regards,
Mani

Blewitt, Alex

unread,
Oct 14, 2013, 9:32:30 AM10/14/13
to mani chandel, repo-d...@googlegroups.com

When you grant all permissions to the .ssh/ folder, you implicitly disable ssh.

 

Alex

mani chandel

unread,
Oct 14, 2013, 9:41:36 AM10/14/13
to Blewitt, Alex, repo-d...@googlegroups.com
Hi Alex,

I just changed the permissions of .ssh to 700, id_rsa to 600 and id_rsa.pub to 644. Still getting the same error.

Regards,
Mani

Saša Živkov

unread,
Oct 14, 2013, 11:41:03 AM10/14/13
to mani chandel, Blewitt, Alex, repo-d...@googlegroups.com
Under which user do you run Jenkins?
Who owns the /home/mani/.ssh/id_rsa file?
$ ls -al /home/mani/.ssh

mani chandel

unread,
Oct 15, 2013, 3:27:05 AM10/15/13
to Saša Živkov, Blewitt, Alex, repo-d...@googlegroups.com
Hi Zivkov,

I have created a user called gerrit_developer in jenkins.
I am running given all rights to this user and am running jenkins with this user.
/home/mani/.ssh/id_rsa is owned by user mani .
output of
$ ls -al /home/mani/.ssh
is
drwx------. 2 mani mani 4096 Oct 15 03:22 .
drwx------. 36 mani mani 4096 Oct 15 03:19 ..
-rw-------. 1 mani mani 1675 Oct 15 03:13 id_rsa
-rw-r--r--. 1 mani mani 408 Oct 15 03:13 id_rsa.pub
-rw-r--r--. 1 mani mani 231 Oct 15 03:22 known_hosts

rgds
mani
 


Luca Milanesio

unread,
Oct 15, 2013, 3:30:54 AM10/15/13
to repo-discuss@googlegroups.com Discussion, Saša Živkov, mani chandel, Alex Blewitt
Hey Mani,
I would suggest you to go through some OpenSSH basics first (what is SSH, SSH keys and how to use it).
Just a simple Googling on "openssh" keyword would work (see for instance http://net.tutsplus.com/tutorials/tools-and-tips/ssh-what-and-how/)

Don't think makes sense to do OpenSSH key management support on the Gerrit mailing list ;-)

Luca.

mani chandel

unread,
Oct 16, 2013, 7:31:08 AM10/16/13
to repo-d...@googlegroups.com, Saša Živkov, mani chandel, Alex Blewitt
Hi All,

I was able to resolve this error.
I had to change the permissions of all files in .ssh folder in /var/lib/jenkins to jenkins.
After that it started working :)

Thanks,
Mani

Mohit Arora

unread,
Oct 19, 2016, 6:59:56 AM10/19/16
to Repo and Gerrit Discussion, ziv...@gmail.com, mani.c...@gmail.com, Alex.B...@gs.com
Hi Could you please guide me how did you solve this?
Facing the same issue

Bassem Rabil

unread,
Oct 19, 2016, 8:40:46 AM10/19/16
to Repo and Gerrit Discussion, ziv...@gmail.com, mani.c...@gmail.com, Alex.B...@gs.com
I guess the issue was the permissions of the .ssh directory, i.e. you need to run the following:
$ chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
Reply all
Reply to author
Forward
0 new messages