Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Setting GIT_SSH programmatically
Setting GIT_SSH programmatically [message #1817156] Sat, 16 November 2019 20:03 Go to next message
Simon Kågedal Reimer is currently offline Simon Kågedal ReimerFriend
Messages: 2
Registered: November 2019
Junior Member
Hi!

I'm getting a org.eclipse.jgit.api.errors.TransportException with an "invalid privatekey:" text when trying to use JGit and a simple call such as:

        Git(repository).fetch().call()


As I found online somewhere, setting the `GIT_SSH` environment variable to ssh solves this problem and works perfectly. However, I would like to do this programmatically in the app. Is there a way to do this?

Regards, Simon
Re: Setting GIT_SSH programmatically [message #1817489 is a reply to message #1817156] Sat, 23 November 2019 18:12 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
JGit reads the environment of the Java process it's running in using System.getenv("GIT_SSH").
Java does not provide a setter to set environment variables from Java.

It may be possible to hack that by using reflection but I wouldn't recommend this since it is most likely not
portable between different OSes and Java versions.
Re: Setting GIT_SSH programmatically [message #1817529 is a reply to message #1817489] Mon, 25 November 2019 12:47 Go to previous messageGo to next message
Simon Kågedal Reimer is currently offline Simon Kågedal ReimerFriend
Messages: 2
Registered: November 2019
Junior Member
Right, thanks! So,. there is no other way to achieve this at the moment? I'm trying instead to replicate it by using my own RemoteSession implementation that basically does what (the private class) ExtSession does but always uses "ssh" as a transport, but haven't gotten it to work so far.
Re: Setting GIT_SSH programmatically [message #1817543 is a reply to message #1817529] Mon, 25 November 2019 15:35 Go to previous message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
You could try installing your own SystemReader instance that overrides getenv() to return whatever the full path to the SSH executable is when asked for "GIT_SSH".
Previous Topic:Git Perspective Unresponsive
Next Topic:what is the of equivalent "git tag --points-at <commitId> in Jgit
Goto Forum:
  


Current Time: Sat Apr 27 02:24:36 GMT 2024

Powered by FUDForum. Page generated in 0.02646 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top