问题
I have been hitting this one for over a day now, it's driving me mad!
- I have Git installed on a Win7 PC, and selected the PuttyGen option on install.
- I have generated ssh keys using PuttyGen; I have added the ssh key to my Git account, and linked the private key in Pageant.
- I have set up GIT_SSH to point to my putty plink.exe.
- I've used Putty to connect to codaset & git to get them accepted as known hosts.
I can clone from the console, but hudson fails:
Fetching upstream changes from git@codaset.com:xxx/xxx.git
[workspace] $ "C:\Program Files\Git\bin\git.exe" fetch -t git@codaset.com:xxx/xxx.git +refs/heads/*:refs/remotes/origin/*
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
...
If I run the exact git command in a console, it works fine:
"C:\Program Files\Git\bin\git.exe" fetch -t git@codaset.com:xxx/xxx.git +refs/heads/*:refs/remotes/origin/*
I have tried running plink to connect directly to GitHub:
plink -agent -v git@github.com
Looking up host "github.com"
...
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using username "git".
...
Authenticating with public key "rsa-key-20110121" from agent
...
Hi xxx! You've successfully authenticated, but GitHub does not provide
shell access.
I then tried connecting to codaset:
plink -agent -v git@codaset.co
m
Looking up host "codaset.com"
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using username "git".
...
Authenticating with public key "rsa-key-20110121" from agent
...
Opened channel for session
Server refused to allocate pty
Started a shell/command
Error: Command is required.
...
Server sent command exit status 255
Disconnected: All channels closed
So, a slightly different response from codaset than from git. However, I think this may be a red herring, as I get the same error if I try to connect to a standard git project from hudson.
I also set up Go Server (CruiseControl as was), and get a similar error when attempting to connect to git from here:
ERROR: FATAL ERROR: Disconnected: No supported authentication methods available
ERROR: fatal: The remote end hung up unexpectedly
Which makes me think the problem must lie with the authentication, rather than the hudson details...?
As always, any help much appreciated!
回答1:
This might be a permissions issue. You can git clone on the same machine, but my guess is that you didn't do it as the same user running Hudson. su to that user, then try again. It may expose the problem.
回答2:
Is hudson running on the same machine that you can successfully fetch from? If not, you probably need to generate an ssh key on that machine as well and add it to your github account.
Either way, the first question (unless I missed it in your question) is where you have hudson running.
回答3:
After a long battle, I resolved this by running hudson from the console, instead of as a service... Not ideal, but at this time on a Friday it's good enough!
回答4:
I received a SSH Fatal Error "server refuse to start a shell/command" when I interact with my called party via Putty Plink.exe
I noticed the problem is that my called party is in the interactive mode. For example, after I connected to the called party, my called party asked me to press any key to continue. After I pressed the Enter key and typed the commands, I need to type "exit", then press "Enter" to exit SSH connection.
To make it interact with the called party, I constructed my commands as below:
Notes: I am using PowerShell code as an example here.
$Commands= @"
show status
exit
exit
"@
Note that each line break in the parameter above represents the "Enter" Key. Then, I passed the Commands parameter to the plink.exe as below:
$output = $Commands |.\Putty\plink.exe -auto_store_key_in_cache -l $UserName -pw $Password $CalledPartyIP -v 2>&1
It will pass a list of commands to plink and output the verbose result to the $output variable.
Hope this helps!
来源:https://stackoverflow.com/questions/4760287/hudson-wont-fetch-from-git