Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Clone Repo with ssh + privatekey
Clone Repo with ssh + privatekey [message #1723572] Tue, 16 February 2016 16:06 Go to next message
Ro Ko is currently offline Ro KoFriend
Messages: 5
Registered: January 2016
Junior Member
hey,

I'm having some problems cloning a repo by ssh using a public key:

public class TakeInit {
	public TakeInit(final String localPath, final String remotePath) {	}

	public void loadRepo(final String localPath, final String remotePath, final String password) {
		SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
			@Override
			protected JSch createDefaultJSch(final FS fs) throws JSchException {
				JSch defaultJSch = super.createDefaultJSch(fs);
				defaultJSch.removeAllIdentity();
				defaultJSch.addIdentity("~/doc/privatekey.ppk");
				return defaultJSch;
			}

			@Override
			protected void configure(final Host hc, final Session session) {
				session.setPassword(password);
				session.setConfig("StrictHostKeyChecking", "no");
			};
		};

		CloneCommand cloneCommand = Git.cloneRepository();
		cloneCommand.setURI(remotePath);
		cloneCommand.setTransportConfigCallback(new TransportConfigCallback() {
			@Override
			public void configure(final Transport transport) {
				SshTransport sshTransport = (SshTransport) transport;
				sshTransport.setSshSessionFactory(sshSessionFactory);
			}
		});

		cloneCommand.setDirectory(new File(localPath));
		try {
			cloneCommand.call();
		} catch (GitAPIException e) {
			e.printStackTrace();
		}
	}
}


I just get "auth failed"

I used snippets from:
codeaffine.com/2014/12/09/jgit-authentication/

maybe someone see my mistake

greetings
Rob

[Updated on: Wed, 17 February 2016 07:35]

Report message to a moderator

Re: Clone Repo with ssh + privatekey [message #1723668 is a reply to message #1723572] Wed, 17 February 2016 07:36 Go to previous message
Ro Ko is currently offline Ro KoFriend
Messages: 5
Registered: January 2016
Junior Member
hey,

new day and I found the mistake:
defaultJSch.addIdentity("~/doc/privatekey.ppk");
has to be
defaultJSch.addIdentity("~/doc/privatekey.ppk", password);

greetingts
Rob
Previous Topic:EGit not playing nice with command-line Git?
Next Topic:Create Remote Repository from client machine
Goto Forum:
  


Current Time: Tue Apr 23 09:44:29 GMT 2024

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

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

Back to the top