我正在尝试用JGit克隆Git仓库,但我对UnsupportedCredentialItem有问题。
我的代码:
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(PATH).readEnvironment().findGitDir().build();
Git git = new Git(repository);
CloneCommand clone = git.cloneRepository();
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setDirectory(PATH).setURI(url);
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(login, password);
clone.setCredentialsProvider(user);
clone.call(); 它将发生异常:
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git@github.com:22: Passphrase for C:\Users\Marek\.ssh\id_rsa at
org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:110)....但是如果我在.ssh\中删除known_hosts文件,会出现不同的异常
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git@github.com:22: The authenticity of host 'github.com' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting?
at org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:110)....有没有可能对这个问题输入“是”或者直接跳过它?
谢谢!
发布于 2012-04-06 09:15:39
我认为如果你使用用户名和密码登录,你需要https。对于ssh,您需要一个与github记录的公钥相匹配的公钥。
发布于 2011-12-20 06:51:01
我想你会想要查看github帮助:
http://help.github.com/win-set-up-git/
特别是关于生成ssh密钥(ssh-keygen -t rsa -C "your_email@youremail.com")的部分。阅读适用于您的环境的文章,您将了解如何获得更好的配置。
发布于 2014-01-13 04:00:24
如果将用户名/密码与ssh一起使用,这将会做到这一点(就像@michals,只是代码更少
public void gitClone() throws GitAPIException {
final File localPath = new File("./TestRepo");
Git.cloneRepository()
.setURI(REMOTE_URL)
.setDirectory(localPath)
.setCredentialsProvider(new UsernamePasswordCredentialsProvider("***", "***"))
.call();
}https://stackoverflow.com/questions/8545311
复制相似问题