Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Unable to connect using SSH in JGit(Unable to connect using SSH in JGit)
Unable to connect using SSH in JGit [message #1829533] Mon, 06 July 2020 09:31
Vipul Agarwal is currently offline Vipul AgarwalFriend
Messages: 1
Registered: July 2020
Junior Member
Hi,

I am trying to connect to github.com using SSH and JGit. This is the code I am trying:-
public static void gitClone(File gitDirectoryPath) throws Exception {
SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
@Override
protected void configure(OpenSshConfig.Host host, Session session) {
session.setUserInfo(new UserInfo() {
@Override
public String getPassphrase() {
return "";
}

@Override
public String getPassword() {
return null;
}

@Override
public boolean promptPassword(String message) {
return false;
}

@Override
public boolean promptPassphrase(String message) {
return true;
}

@Override
public boolean promptYesNo(String message) {
return false;
}

@Override
public void showMessage(String message) {
}
});
}
};

Git.cloneRepository().setTransportConfigCallback(new SshTransportConfigCallback()).setURI("git@github.com:agarwalvipul/core-java-template.git")
.setDirectory(gitDirectoryPath).call();

}

private static class SshTransportConfigCallback implements TransportConfigCallback {
private final SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
@Override
protected void configure(OpenSshConfig.Host hc, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
}
};

@Override
public void configure(Transport transport) {
SshTransport sshTransport = (SshTransport) transport;
sshTransport.setSshSessionFactory(sshSessionFactory);
}
}

I am getting the following exception:-
Exception in thread "main" org.eclipse.jgit.api.errors.TransportException: git@github.com:agarwalvipul/core-java-template.git: Auth fail
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:252)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200)
at com.lm.expertfees.Github.gitClone(Github.java:60)
at com.lm.expertfees.Test.main(Test.java:10)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.com:agarwalvipul/core-java-template.git: Auth fail
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:182)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:137)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1269)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:241)
... 4 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:519)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:136)
... 11 more


Can anyone help me in this context?
Previous Topic:not authorized
Next Topic:Fetch configuration after cloning
Goto Forum:
  


Current Time: Thu Jun 24 13:19:34 GMT 2021

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

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

Back to the top