Clone Repo with ssh + privatekey [message #1723572] |
Tue, 16 February 2016 16:06 |
Ro Ko 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03773 seconds