Bug 580740 - Add "-ssh" argument when using GIT_SSH with plink
Summary: Add "-ssh" argument when using GIT_SSH with plink
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-15 08:44 EDT by Carsten Pfeiffer CLA
Modified: 2022-09-15 08:59 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Pfeiffer CLA 2022-09-15 08:44:56 EDT
When trying to fetch or push on Windows with GIT_SSH=/path/to/plink.exe the connection may fail with an error like "Connection refused" or "Invalid remote: origin".

We found out that this was due to the "default session" in putty being misconfigured. Putty supports different kinds of sessions (ssh/tcp/rlogin/raw), and in this case, the default was configured to be a raw connection.

Since I suspect that jgit is supposed to connect to a git repository via ssh when using an ssh-url, it might make sense to explicitly request that by adding "-ssh" to the plink commandline at https://git.eclipse.org/c/jgit/jgit.git/tree/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java?h=master#n226
Most people probably don't even know that there is a "default session" in putty or that it would have an impact on eclipse connecting to a git repository.

See
https://the.earth.li/~sgtatham/putty/0.77/htmldoc/Chapter7.html#plink-usage-batch
Comment 1 Carsten Pfeiffer CLA 2022-09-15 08:46:50 EDT
Here's a stacktrace that we got (I had to run an image through OCR, so there may be wrong characters).

!ENTRY org.eclipse.egit.core 4 0 2022-09-15 12:49:13.406
!MESSAGE Pulling 1 repository 
!SUBENTRY 1 org.eclipse.egit.core 4 0 2022-09-15 12:49:13.409 
!MESSAGE Invalid remote: origin 
!STACK 0 
org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin
	at org.eclipse.jgit.api.FetchCommand.call(FetchCcommnd.java:221)
	at org.eclipse.jgit.api.PullCommand.call(PullConmmnd.java:266)
	at org.eclipse.egit.core.op.PullOperation$PullJob.run(PullOperation.java:256)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: ssh://git@gitlab.xxx/foo/bar.git FATAL ERROR: Network error: Connection refused 
	at org.eclipse.jgit.transport.TransportGitSsh.cleanNotFound(TransportGitSsh.java:201) 
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.Einit>(TransportGitSsh.java:325)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:153)
	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:142)
	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:94)
	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1309)
	at org.eclipse.jgit.api.FetchConmmnd.call(FetchComnmnd.java:213)
	... 3 more