Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] git clone via secured connection

Hi,

Iam trying to clone a repository with jgit and jsch but Iam always getting an Auth fail with my self written client, but on another computer it works fine with this URL. I putted the user in the URL to avoid trouble with the username, Iam using keys that have the same name on the server and the client and no password.

org.eclipse.jgit.api.errors.TransportException: ssh://git@server:port/testrepo.git: Auth fail 03:09:30.560 23627/23627 System.err W at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137) 03:09:30.560 23627/23627 System.err W at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) 03:09:30.560 23627/23627 System.err W at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125) 03:09:30.560 23627/23627 System.err W at com.example.git.GitRepository.clone(GitRepository.java:342) 03:09:30.560 23627/23627 System.err W at com.example.git.GitRepository.<init>(GitRepository.java:73) 03:09:30.560 23627/23627 System.err W at com.example.git.MainActivity$3$1.onClick(MainActivity.java:140) 03:09:30.560 23627/23627 System.err W at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158) 03:09:30.560 23627/23627 System.err W at android.os.Handler.dispatchMessage(Handler.java:99) 03:09:30.560 23627/23627 System.err W at android.os.Looper.loop(Looper.java:143) 03:09:30.560 23627/23627 System.err W at android.app.ActivityThread.main(ActivityThread.java:4717) 03:09:30.560 23627/23627 System.err W at java.lang.reflect.Method.invokeNative(Native Method) 03:09:30.560 23627/23627 System.err W at java.lang.reflect.Method.invoke(Method.java:521) 03:09:30.560 23627/23627 System.err W at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 03:09:30.560 23627/23627 System.err W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 03:09:30.560 23627/23627 System.err W at dalvik.system.NativeStart.main(Native Method) 03:09:30.560 23627/23627 System.err W Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@server:port/testrepo.git: Auth fail 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1104) 03:09:30.568 23627/23627 System.err W at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
03:09:30.568 23627/23627                System.err  W       ... 14 more
03:09:30.568 23627/23627 System.err W Caused by: com.jcraft.jsch.JSchException: Auth fail 03:09:30.576 23627/23627 System.err W at com.jcraft.jsch.Session.connect(Session.java:491) 03:09:30.576 23627/23627 System.err W at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
03:09:30.576 23627/23627                System.err  W       ... 21 more

The pub key:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtjpIrjtrDAA5Y8lO+qCdqKIRP6HP3orKCsiOaHPJ589An9PPK/1Sy28UDVmLT6RextXrMO9SkC0UOrpHsTf/EqhMtRdCby4TvCC98I4vQ/5SJkKrm8PKV... ...//Xt8i7pM4fyVqzNrJz914AIf9oszGbrIvbbJqgmCnQdPOcfhDF user@android

And my code:
public class CustomJschConfigSessionFactory extends JschConfigSessionFactory {
  @Override
  protected void configure(OpenSshConfig.Host host, Session session) {
      session.setConfig("StrictHostKeyChecking", "no");
  }
}

The settings and clonging part:
CloneCommand clone = git.cloneRepository();
     try {
CustomJschConfigSessionFactory jschConfigSessionFactory = new CustomJschConfigSessionFactory();
         JSch jsch = new JSch();
         jsch.addIdentity(pathToKey);
         SshSessionFactory.setInstance(jschConfigSessionFactory);
         clone.setCloneAllBranches(true);
         clone.setDirectory(new File(path + "/"));
         clone.setURI(uri);
         clone.call();
         cloneSuccesfull = true;
  }

Is it necessary to add a CredentialProvider? If yes, what should be provided there and how? Or could be the problem, the user@android Iam not sure what the real hostname of the devise or the username is.

Thanks in advance,
Flask


Back to the top