2014-12-19 13 views
4

라이브러리 nodegit (버전 0.2.4) 및 ssh를 사용하여 node.js의 teamforge 서버에서 git 저장소를 복제하려고합니다. 우리 서버가 사용자로부터 인증을 요청하고 옵션을 전달하지 않고 복제 메소드 만 사용하려고 할 때 "콜백이 SSH 자격 증명을 초기화하지 못했습니다"라는 오류가 발생했습니다.ssh를 사용하여 git 저장소와 노드 킷을 복제하는 방법

private.key 및 public.key 파일에 개인 키와 공개 키가 있습니다. 그것들은 웹 폭풍우에서 작업 디렉토리로 설정 한 디렉토리에 있으므로 위치가 문제가되지 않아야합니다.

방법을 (어쩌면 내가 그것을 놓친) 수행하는 예를 찾을 수 있지만, 코드 아래에 내가 가지고있는 가장 가까운하지 않았나요 :

TypeError: Object #<Object> has no method 'isFulfilled' at value 
(c:\...\proj\node_modules\nodegit\node_modules\nodegit-promise\lib\core.js:36:15) 
:이 오류를 받고 있어요

'use strict'; 

var nodegit = require("nodegit"), 
Clone = nodegit.Clone, 
cred = nodegit.Cred; 

var options = { 
    remoteCallbacks: { 
     credentials: function() { 
      return cred.sshKeyNew('user', 'public.key', 'private.key', ''); 
     } 
    } 
}; 

Clone.clone("ssh://[email protected]/reponame", "localTmp", options) 
    .then(function(repo) { 
     var r = repo; 
    }, 
    function(err){ 
     var e = err; 
    } 
); 

무엇이 잘못되었거나 일반적으로 어떻게 할 수 있는지 힌트를 가지고 있습니까?

답변

4

이것은 새로운 ssh 키를 만드는 버그입니다. 나는 그것을 추적하기 위해 here 호를 작성했습니다.

SSH 에이전트를 실행하고있는 동안에는 자격 증명을 얻을 수 있습니다.

'use strict'; 

var nodegit = require("nodegit"), 
Clone = nodegit.Clone, 
cred = nodegit.Cred; 

var options = { 
    fetchOpts: { 
     remoteCallbacks: { 
      credentials: function (url, userName) { 
       // this is changed from sshKeyNew to sshKeyFromAgent 
       return cred.sshKeyFromAgent(userName); 
      } 
     } 
    } 
}; 

Clone.clone("ssh://[email protected]/reponame", "localTmp", options) 
    .then(function(repo) { 
     var r = repo; 
    }, 
    function(err){ 
     var e = err; 
    } 
); 

나를 위해 v0.2.4에서 작동합니다. 더 많은 실시간 지원이 필요하시면 our gitter channel에서 우리와 채팅하십시오.

업데이트 : 방금 Pull Request #334에 대한 수정 사항을 추가했습니다. 테스트가 통과 된 후 나는 이것을 master에 놓을 것이고 질문에있는 코드는 잘 동작 할 것이다.

+0

이 줄은 ssh url과 디렉토리 이름을 바꿔 줄 뿐이며'Error : authentication required but callback set'을 받았습니다. – TheEnvironmentalist

+1

nodegit api에 변화가있었습니다. 이 옵션 내에서,'remoteCallbacks'를 여기서 정의 된'callbacks'로 대체하십시오 : http://www.nodegit.org/api/fetch_options/ – bumblebee