foundweekends / giter8

a command line tool to apply templates defined on GitHub
https://www.foundweekends.org/giter8/
Apache License 2.0
1.74k stars 223 forks source link

GitHub Auth Fail on private repo #94

Closed taylorleese closed 10 years ago

taylorleese commented 11 years ago

Using 0.5.3 I receive a GitHub auth fail. I already ran cs --auth user:pass and I see the app with private repo access in account settings in GitHub. It still fails with the error below.

taylor:tmp taylor$ g8 stackmob/service-template
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:138)
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:175)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:121)
    at giter8.Apply$class.clone(apply.scala:38)
    at giter8.Giter8.clone(giter8.scala:3)
    at giter8.Apply$class.inspect(apply.scala:21)
    at giter8.Giter8.inspect(giter8.scala:3)
    at giter8.Giter8.ghInspect(giter8.scala:56)
    at giter8.Giter8.run(giter8.scala:24)
    at giter8.Giter8.run(giter8.scala:12)
    at giter8.Giter8.run(giter8.scala:3)
    at xsbt.boot.Launch$.run(Launch.scala:54)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43)
    at xsbt.boot.Launch$.launch(Launch.scala:68)
    at xsbt.boot.Launch$.apply(Launch.scala:14)
    at xsbt.boot.Boot$.runImpl(Boot.scala:25)
    at xsbt.boot.Boot$.main(Boot.scala:15)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.com:stackmob/service-template.g8.git: Auth fail
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:141)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
    at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:127)
    at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:113)
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1062)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:129)
    ... 17 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:461)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    ... 24 more
Error during sbt execution: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
taylorleese commented 11 years ago

Just realized I opened a similar issue 3 months ago: https://github.com/n8han/giter8/issues/82

n8han commented 11 years ago

In giter8 0.5.3 your github username and password are no longer used for private repo access. Instead, jgit is using ssh to try to fetch the private repo. In most configurations this works without you having to do anything.

I assume that you can clone the repository in question using plain git, logged in as the same user?

taylorleese commented 11 years ago

Correct, I can clone and push to it fine. Perhaps the fact that the repo is a private repo for our organization rather than an individual user makes a difference.

jacksonja commented 11 years ago

I am also experiencing this issue with templates on a public github repo.

quii commented 11 years ago

Me too

I suspect it is some kind of configuration problem on my system though. It works on my colleague's computer but not mine.

I am able to clone the g8 template with no problems though

Caused by: org.eclipse.jgit.errors.TransportException: Auth Fail

reinouts commented 11 years ago

+1 for this issue. Any workarounds?

caoilte commented 11 years ago

Same problem (public repos). MacOSX. Mountain Lion. Using ssh+git fine everywhere else.

amanbhurji commented 11 years ago

I have the same error on 'g8 scalatra/scalatra-sbt' which is a public repo. Also on MacOSX, Mountain Lion.

flurdy commented 11 years ago

My workaround is to clone the repo locally and then use the file path with g8. E.g g8 file://pathtorepo

danhper commented 11 years ago

Same problem for me when running g8 scalatra/scalatra-sbt. I did not have any problem using @flurdy workaround though.

jimschubert commented 11 years ago

I've hit the same issue with g8 0.5.3. I'm on Mac OS X 10.8.5 and installed giter8 via brew.

Here's the output of the error:

$ g8 typesafehub/play-scala
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:138)
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:175)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:121)
    at giter8.Apply$class.clone(apply.scala:38)
    at giter8.Giter8.clone(giter8.scala:3)
    at giter8.Apply$class.inspect(apply.scala:21)
    at giter8.Giter8.inspect(giter8.scala:3)
    at giter8.Giter8.ghInspect(giter8.scala:56)
    at giter8.Giter8.run(giter8.scala:24)
    at giter8.Giter8.run(giter8.scala:12)
    at giter8.Giter8.run(giter8.scala:3)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.com:typesafehub/play-scala.g8.git: Auth fail
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:141)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
    at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:127)
    at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:113)
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1062)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:129)
    ... 19 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:461)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    ... 26 more
Error during sbt execution: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command

I initially thought this issue was caused by a recent upgrade of git to version 1.8.4, so I rolled back to 1.7.10.2 (the version installed on my machine by default). I had the same issue, so I wondered if this was a result of my corporate network blocking the git://. I tried explicitly providing the full repo and received an error I'd expect for the blocked protocol:

$ g8 git://www.github.com/typesafehub/play-scala.git
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:138)
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:175)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:121)
    at giter8.Apply$class.clone(apply.scala:38)
    at giter8.Giter8.clone(giter8.scala:3)
    at giter8.Apply$class.inspect(apply.scala:21)
    at giter8.Giter8.inspect(giter8.scala:3)
    at giter8.Giter8.run(giter8.scala:28)
    at giter8.Giter8.run(giter8.scala:12)
    at giter8.Giter8.run(giter8.scala:3)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: org.eclipse.jgit.errors.TransportException: git://www.github.com/typesafehub/play-scala.git: Connection refused
    at org.eclipse.jgit.transport.TransportGitAnon.openConnection(TransportGitAnon.java:141)
    at org.eclipse.jgit.transport.TransportGitAnon$TcpFetchConnection.<init>(TransportGitAnon.java:170)
    at org.eclipse.jgit.transport.TransportGitAnon.openFetch(TransportGitAnon.java:111)
    at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:127)
    at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:113)
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1062)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:129)
    ... 18 more
Error during sbt execution: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command

I tried with the https:// protocol of the repo (with and without the .git suffix):

$ g8 https://github.com/typesafehub/play-scala

giter8 0.5.3
Usage: g8 [TEMPLATE] [OPTION]...
Apply specified template.

OPTIONS
    -b, --branch
        Resolves a template within a given branch
    --paramname=paramvalue
        Set given parameter value and bypass interaction.

Apply template and interactively fulfill parameters.
    g8 n8han/giter8

Or
    g8 git://github.com/n8han/giter8.git

Apply template from a remote branch
    g8 n8han/giter8 -b some-branch

Apply template from a local repo
    g8 file://path/to/the/repo

Apply given name parameter and use defaults for all others.
    g8 n8han/giter8 --name=template-test

Apparently, https transport is broken in 0.5.3 on brew. I rolled back to the previous version and everything works. Here's how I rolled back:

$ cd /usr/local/Library
$ # brew versions giter8
$ git checkout 3c5ca25 /usr/local/Library/Formula/giter8.rb
$ brew unlink giter8 && brew install giter8

Now, g8 typesafehub/play-scala works as expected.

rburgosnavas commented 10 years ago

flurdy's workaround works great.

eskatos commented 10 years ago

Warning: brew-versions is unsupported and will be removed soon.

Moreover, looks like 0.6.2 is still affected by this issue.

eskatos commented 10 years ago

Using ssh based access with an unprotected key works with 0.6.2.

But one doesn't want unprotected keys...

Looks like it will be fixed in 0.6.7: de3b0840b959aa8436a235d2f1b1044a70680f9d Didn't try it yet though.

As a side note, Homebrew folks have a hard time packaging giter8, see the discussion in https://github.com/Homebrew/homebrew/pull/29614

n8han commented 10 years ago

Should be fixed in #141.

devshorts commented 8 years ago

SSH access to a private repo still doesn't work with g8 0.7.1, is this a known issue? I'm trying to access a g8 template in a github private repo and I get the same error as posted above

jasonmartens commented 7 years ago

I am getting this error if my ssh key is not stored in ~/.ssh/id_rsa. It seems that jgit only looks for a few file names as valid ssh host keys, and it doesn't check the ssh-agent: https://github.com/eclipse/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java#L323 .

iandrosov commented 7 years ago

Getting same error trying to clone private repo locally with Java code. git clone works fine but inside Java exception error. I did try all varioation of URI with .git, without with :22, with moving Org name around still same error

org.eclipse.jgit.api.errors.TransportException: ssh://github.com/Bisk/skyway-salesforce-dev: Auth fail at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:224) at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:216) at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:137) at com.force.deploy.jgit.CloneRemoteRepositoryWithAuthentication.cloneRepo(CloneRemoteRepositoryWithAuthentication.java:76) at com.force.deploy.start.StartController.git(StartController.java:91) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.eclipse.jgit.errors.TransportException: ssh://github.com/Bisk/skyway-salesforce-dev: Auth fail at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:160) at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:137) at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:274) at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:169) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1236) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:213) ... 58 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:117) ... 65 more

iandrosov commented 7 years ago

Problem solved by using https with different credential provider user/password instead of SSH. Using this code instead CloneCommand cloneCommand = Git.cloneRepository(); cloneCommand.setURI( "https://example.com/repo.git" ); cloneCommand.setCredentialsProvider( new UsernamePasswordCredentialsProvider( "user", "password" ) );

As documented http://www.codeaffine.com/2014/12/09/jgit-authentication/

TonioGela commented 4 years ago

+1 still doesn't work despite the key is ~/.ssh/id_rsa