Using putty's pagent with egit in Eclipse

房东的猫 提交于 2019-12-18 13:23:38

问题


I'm trying to access a private remote SSH git repository via the Eclipse 'egit' module. I'm running Eclipse on Windows. Eclipse doesn't seem to automagically work with putty's pagent for authorization forwarding and I can't find any documentation about customizing the SSH used by egit (e.g., to use plink.exe).

I've found documentation on the web about setting up other Windows git clients to use putty/plink (e.g., for msysgit), but I can't seem to find anything about Eclipse's egit and putty (or eclipse).

I'm confident the ssh key works normally, as I use it all the time to log into the server with Putty.

Specifically, I use the Git Repository Viewer, click 'Clone Remote Repository', fill in the host, repository path, protocol (ssh), and user. I Click 'Next'. I can tell that its connecting because I get a pop-up with my server's unique banner. Then I get a

Transport Error: Cannot list the available branches: Reason: <URI>: Auth fail

The ssh login is by sshkey only, so that's why this doesn't work (but at least it shows I've got the basics down).

Anyone have success with egit+pageant? Or know if its just not possible?

Update

It seems that this doesn't work because Eclipse has a pure-Java SSH (jsch) implementation internally that it uses, and that implementation Eclipse contains does not (yet) support the authorization agent protocols.

Some patches to support platform ssh agents via the have been proposed (thanks to @Janning for the link). See this Eclipse bug 179924. Update #24 includes this encouraging note about the proposed patches:

I have confirmed that I can get accesses to http://github.com/ and clone some projects by egit with putty's pageant.

I'm not entirely sure, but it seems like the current hangups are some licensing issues around a pure-java unix-domain socket library, and upgrading the pure-java SSH implementation that Eclipse uses.

A more recent bug (number 360663) shows the required version of jsch has been committed to Eclipse (and as far as I can tell should be part of the next release -- should be end of June 2012).


回答1:


After reading morellet.d's answer, I was able to set this up for myself very simply.

I added the user environment variable GIT_SSH and set it to "C:\Program Files (x86)\PuTTY\plink.exe" So, you just need to set it to wherever your plink file is and it will work.

Instructions worked with PuTTY 0.62, the latest EGit and Eclipse Juno x64.




回答2:


Found a better solution allows using pagent key rather then eclipse(openssh) key. For me or someone else try to use Eclipse, GitBash, with plink and pagent (with or without keepass) on Windows.

The root cause is that, the error message lie. It may caused by failed to call plink.exe due to invalid parameter and nothing related to the server key. (JGIT developer should fix).

EGIT use JGit, and it pass argument to "-p [port] [server] "git-upload-pack '[project]'" plink.exe.

The argument is good for openssh, however, which is not compatible with plink.exe , plink.exe requires capital "-P" for ssh port.


Save this file as "plink.cmd"

@ECHO OFF
SET c="plink.exe" -ssh -agent -l [username]

:loop
if NOT _%1_ == __ (
 IF _%1_ == _-p_ (
  SET c=%C% -P
 ) else (
  SET c=%C% %1
 )
 shift
 goto loop
)
%c%

In windows, run SETX GIT_SSH PATH_TO\plink.cmd to upload environment variable.


Enjoy connection of pagent with your Eclipse and GIT Bash for windows.




回答3:


eGit is using the SSH keys that Eclipse's built-in SSH functionality knows about. Load the keys into the SSH2 preference page shown at http://wiki.eclipse.org/EGit/User_Guide#Eclipse_SSH_Configuration .




回答4:


EGit + pageant actually works for me (contrary to the Eclipse SSH2 home/private key configuration...)

I am on Windows 7 with TortoiseGit + msysgit installed.

In the User Settings tab in Team > Git > Configuration I only put my name and email address and the signinkey is empty. In the Repository Settings tab, the url is copy&pasted from github's ssh link and the puttykey path is correct (for ex. C:\Users\you\.ssh\yourkey.ppk). I am using a key without passphrase.

I also added the following windows system variable : GIT_SSH=C:\\Program Files\\TortoiseGit\\bin\\TortoisePlink.exe

Once the pageant is started with the key added it should work...



来源:https://stackoverflow.com/questions/7762139/using-puttys-pagent-with-egit-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!