Starting a job with jenkins user gives ssh error

344 views
Skip to first unread message

mani chandel

unread,
Oct 10, 2013, 9:24:13 AM10/10/13
to repo-d...@googlegroups.com
Hi All,
 
I am trying to integrate Jenkins with gerrit on my local environment.
I started a job with Jenkins users but it gives me this below error. Please help.
 
Started by user gerrit developer
Building in workspace C:\Program Files\Jenkins\jobs\test_job3\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson2558238243811788130.bat

C:\Program Files\Jenkins\jobs\test_job3\workspace>ssh -p 29418 gerrit_developer@localhost gerrit ls-projects  1>>logfile.txt 
Permission denied (publickey).

C:\Program Files\Jenkins\jobs\test_job3\workspace>exit 255 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
 
Regards,
Mani

Thomas Swindells (tswindel)

unread,
Oct 10, 2013, 10:03:15 AM10/10/13
to mani chandel, repo-d...@googlegroups.com

You need to make sure the public key is available for the user the Jenkins service is running out to allow it to login to Gerrit.

This won’t be the same as the user of the person logged into the desktop.

 

Note if you use the Jenkins Gerrit Trigger Plugin then it gives you the option to specify the keyfile.

 

 

Thomas

--
--
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.

Magnus Bäck

unread,
Oct 10, 2013, 10:05:08 AM10/10/13
to repo-d...@googlegroups.com
On Thursday, October 10, 2013 at 09:24 EDT,
mani chandel <mani.c...@gmail.com> wrote:

> I am trying to integrate Jenkins with gerrit on my local environment.
> I started a job with Jenkins users but it gives me this below error.
> Please help.
>
> Started by user *gerrit developer* <http://localhost:8081/user/gerrit_developer>
> Building in workspace C:\Program Files\Jenkins\jobs\test_job3\workspace
> [workspace] $ cmd /c call C:\Windows\TEMP\hudson2558238243811788130.bat
>
> C:\Program Files\Jenkins\jobs\test_job3\workspace>ssh -p 29418 gerrit_developer@localhost gerrit ls-projects 1>>logfile.txt
> Permission denied (publickey).
>
> C:\Program Files\Jenkins\jobs\test_job3\workspace>exit 255
> Build step 'Execute Windows batch command' marked build as failure
> Finished: FAILURE

http://gerrit-documentation.googlecode.com/svn/Documentation/2.7/error-permission-denied.html

If you can't interpret the output of 'ssh -vv ...', we can help and
suggest the next steps.

--
Magnus Bäck
ba...@google.com

mani chandel

unread,
Oct 10, 2013, 10:25:23 AM10/10/13
to repo-d...@googlegroups.com
Hi Thomas,
 
I have specified the ssh keyfile in the gerrit trgger as below and also clicked on test connection. It shows success. However, I still face this issue. Please let me know if I am missing something.
Gerrit Server
 HostnameHelp for feature: Hostname
Loading...
 Frontend URLHelp for feature: Frontend URL
Loading...
 SSH PortHelp for feature: SSH Port
Loading...
 ProxyHelp for feature: Proxy
Loading...
 UsernameHelp for feature: Username
Loading...
 E-mailHelp for feature: E-mail
Loading...
 SSH KeyfileHelp for feature: SSH Keyfile
Loading...
 SSH Keyfile PasswordHelp for feature: SSH Keyfile Password
Loading...
 Build Current Patches OnlyHelp for feature: Build Current Patches Only
Loading...
 

 

 

 

Hi Magnus,

On executing this command on cmd ssh -vv -p 29418 gerrit_developer@localhost I get below output.

debug2: channel 0: input open -> closed
debug2: channel 0: obuf_empty delayed efd 6/(294)

  ****    Welcome to Gerrit Code Review    ****

  Hi gerrit developer, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://gerrit_developer@<IP address>/REPOSITORY_NAME.git

 

Regards,

Mani

 

Thomas Swindells (tswindel)

unread,
Oct 10, 2013, 10:28:33 AM10/10/13
to mani chandel, repo-d...@googlegroups.com

The gerrit trigger config will only control the ssh key used by the Gerrit trigger to perform the polling.

The actual git clone command is separate from this and run on whatever machine the Jenkins executor is running on (presumably in this case your local machine) and this command has to have had its git ssh setup done correctly.

 

Thomas

 

From: repo-d...@googlegroups.com [mailto:repo-d...@googlegroups.com] On Behalf Of mani chandel
Sent: 10 October 2013 15:25
To: repo-d...@googlegroups.com
Subject: Re: Starting a job with jenkins user gives ssh error

 

Hi Thomas,

 

I have specified the ssh keyfile in the gerrit trgger as below and also clicked on test connection. It shows success. However, I still face this issue. Please let me know if I am missing something.

Gerrit Server

 

Hostname

localhost

Image removed by sender. Help for feature: Hostname

Loading...

 

Frontend URL

http://localhost:8080/

Image removed by sender. Help for feature: Frontend URL

Loading...

 

SSH Port

29418

Image removed by sender. Help for feature: SSH Port

Loading...

 

Proxy

Image removed by sender. Help for feature: Proxy

Loading...

 

Username

gerrit_developer

Image removed by sender. Help for feature: Username

Loading...

 

E-mail

Image removed by sender. Help for feature: E-mail

Loading...

 

SSH Keyfile

C:\Users\253673\.ssh\id_rsa

Image removed by sender. Help for feature: SSH Keyfile

Loading...

 

SSH Keyfile Password

[          ]

Image removed by sender. Help for feature: SSH Keyfile Password

Loading...

 

Build Current Patches Only

[ ]

Image removed by sender. Help for feature: Build Current Patches Only

--

Luca Milanesio

unread,
Oct 10, 2013, 10:29:32 AM10/10/13
to mani chandel, repo-d...@googlegroups.com
My 2 cents: possibly Jenkins NOT running under user "253673" ? 

;-)

Luca.

mani chandel

unread,
Oct 10, 2013, 10:35:53 AM10/10/13
to repo-d...@googlegroups.com, mani chandel
Hi Luca,

I have logged into my computer with user 253673.
And for jenkins I have created a user called gerrit_developer and have given all rights to it.
I am running jenkins with gerrit_developer user.
I have set the  HOME variable in windows which points to my user profile C:\Users\253673 where I have kept the .ssh folder which contains id_rsa keys (private and public).

Regards,
Mani

;-)

Luca.

 
 
 
 

Hi Magnus,

On executing this command on cmd ssh -vv -p 29418 gerrit_d...@localhost I get below output.

Luca Milanesio

unread,
Oct 10, 2013, 10:41:59 AM10/10/13
to mani chandel, repo-d...@googlegroups.com
So, that's the problem: Jenkins needs to run under the user 253673 *OR* assign the keys to your gerrit_developer user.
Example: I am user A and I use SSH keys of user A. If a login as user B I cannot use A's SSH keys.

This is not Gerrit or Jenkins specific concepts, it's simply SSH :-)

Luca.

mani chandel

unread,
Oct 10, 2013, 10:51:47 AM10/10/13
to repo-d...@googlegroups.com, mani chandel
Hi Luca,

Gerrit_developer is my jenkins user.
Please let me know how can I assign SSH key of 253673 to this user.
I am running jenkins and gerrit both on localhost.
Regards,
Mani

Luca Milanesio

unread,
Oct 10, 2013, 10:57:35 AM10/10/13
to mani chandel, repo-d...@googlegroups.com
Try with:
C:\> COPY C:\Users\253673\.ssh\*.* C:\Users\gerrit_developer\.ssh

Luca.
Reply all
Reply to author
Forward
0 new messages