Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to ignore .ssh/config?(Configuring JSchConfigSessionFactory to ignore .ssh/config)
How to ignore .ssh/config? [message #1777615] Thu, 30 November 2017 19:05 Go to next message
Dave Musicant is currently offline Dave MusicantFriend
Messages: 15
Registered: May 2016
Junior Member
I'm trying to write some automated tests that wrap around ssh authentication that I've otherwise got successfully working.

I'm using the approach described here:

http://www.codeaffine.com/2014/12/09/jgit-authentication/

where I'm subclassing JSchConfigSessionFactory, and overriding the configure method. I'm also overriding the createDefaultJSch method so I can supply public/private keys that I've created specifically for the automated test. This all works great.

The problem I'm having is that when I run my tests, the SSH connection attempt still tries keys specified in my .ssh/config. I don't want it to do this, since that means the tests will run differently for different developers depending on their own personal .ssh/config files. I want it to completely ignore that file for purposes of the test.

I've tried doing

defaultJSch.removeAllIdentity()

... but this doesn't seem to help. Strangely, when I use defaultJSch.getIdentityNames, it only shows the keys I have configured; but when I actually use the JGit API to try to do something requiring a connection, the .ssh/config settings seem to be invoked. When I enable JSch detailed debugging logging, I can see that it's trying to connect via a key specified in my .ssh/config.

It's possible I'm doing something wrong and don't know it, but I wanted to check here first to see if there's a clear-cut and simple way to tell JSchConfigSessionFactory to completely avoid the .ssh/config file.

Thanks!
Re: How to ignore .ssh/config? [message #1777661 is a reply to message #1777615] Fri, 01 December 2017 10:17 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
this was recently added in https://git.eclipse.org/r/#/c/99067/ which implements the loading of ~/.ssh/config which is missing in jsch in jgit
Re: How to ignore .ssh/config? [message #1777676 is a reply to message #1777661] Fri, 01 December 2017 11:53 Go to previous messageGo to next message
Dave Musicant is currently offline Dave MusicantFriend
Messages: 15
Registered: May 2016
Junior Member
Matthias Sohn wrote on Fri, 01 December 2017 10:17
this was recently added in https://git.eclipse.org/r/#/c/99067/ which implements the loading of ~/.ssh/config which is missing in jsch in jgit


I've looked at the patch and the test code, thanks. Does this mean that if I create my own ConfigRepository using OpenSshConfig that it will ignore what's in .ssh/config? Or do I still need to first clear that out somehow?
Re: How to ignore .ssh/config? [message #1777897 is a reply to message #1777676] Tue, 05 December 2017 17:47 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
I think you should be able to override JschConfigSessionFactory.getJsch() and just set a ConfigRepository that always returns an empty Config from getConfig().

[Updated on: Tue, 05 December 2017 17:48]

Report message to a moderator

Re: How to ignore .ssh/config? [message #1778615 is a reply to message #1777897] Mon, 18 December 2017 19:16 Go to previous message
Dave Musicant is currently offline Dave MusicantFriend
Messages: 15
Registered: May 2016
Junior Member
I got diverted to other projects (apologies for the delay), but I wanted to say thank you for the help! This definitely points me in the right direction.
Previous Topic:How to integrate EGit into a mixed e3/e4 RCP application
Next Topic:Hard reset isn't erasing local commits
Goto Forum:
  


Current Time: Tue Apr 23 16:24:56 GMT 2024

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

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

Back to the top