Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Setting GIT_SSH programmatically
Setting GIT_SSH programmatically [message #1817156] Sat, 16 November 2019 15:03 Go to next message
Eclipse UserFriend
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 13:12 Go to previous messageGo to next message
Eclipse UserFriend
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 07:47 Go to previous messageGo to next message
Eclipse UserFriend
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 10:35 Go to previous message
Eclipse UserFriend
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 Jul 05 08:48:36 EDT 2025

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

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

Back to the top