Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Create bare Jgit repo with public ssh key auth(Need to write test case which can clone repo with ssh private key)
Create bare Jgit repo with public ssh key auth [message #1794482] Fri, 31 August 2018 07:21 Go to next message
Shashank Singh is currently offline Shashank SinghFriend
Messages: 1
Registered: August 2018
Junior Member
To write test case which can clone a repo with ssh private key, we need to create a bare Git repo which we can create with ssh public key user.

The code I'm using to create bare repo:
File root = new File("target/junk/repo");
File bareRoot = new File("target/junk/bare-repo.git");
Git bare = createBareRepository(bareRoot);
Git.init().setDirectory(root).setBare(true).call();


And this is how I'll like to clone the repo in my unit test
Git.cloneRepository()
        .setURI(url)
        .setRemote(remote)
        .setDirectory(path)
        .setTransportConfigCallback(new TransportConfigCallback() {
        @Override
        public void configure( Transport transport ) {
          SshTransport sshTransport = ( SshTransport )transport;
          sshTransport.setSshSessionFactory( sshSessionFactory );
        }
      }).call();

Re: Create bare Jgit repo with public ssh key auth [message #1794505 is a reply to message #1794482] Fri, 31 August 2018 14:31 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
I am not sure what is your question ?

If you want to create a repository remotely over ssh git protocol, this is not possible since the git protocol
(also git over ssh or git over https) doesn't support that.

You can create a repository locally in the way you described above. In order to serve it via ssh you need
a ssh daemon implementation. JGit doesn't have any. You may have a look at how Gerrit implements that [1]
using Apache Mina SSHD.

[1] https://gerrit.googlesource.com/gerrit/+/master/java/com/google/gerrit/sshd/SshDaemon.java
Previous Topic:Wanna use 'org.eclipse.egit.github.core' in a project
Next Topic:Does EGit 5.x support the Git protocol version 2?
Goto Forum:
  


Current Time: Tue Apr 16 09:25:37 GMT 2024

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

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

Back to the top