【发布时间】:2013-03-10 09:21:40
【问题描述】:
# Write the SSH-KEY to the disk
fs.writeFile "/cgrepos/.ssh/#{repo.id}.pub", repo.public_key, (err) ->
throw err if err
fs.writeFile "/cgrepos/.ssh/#{repo.id}", repo.private_key, (err) ->
throw err if err
exec "chmod 400 /cgrepos/.ssh/#{repo.id} && eval `ssh-agent -s` && ssh-add /cgrepos/.ssh/#{repo.id}", (error) ->
throw error if error
# First, delete the git repo on the hard drive, if it exists
exec "rm -rf #{git_location}", options, (error) ->
throw error if error
# Second, clone the repo into the location
console.log "Cloning repo #{repo.id}: #{repo.repo_name} into #{git_location}. This could take a minute"
exec "git clone #{repo.url} #{git_location}", options, (error) ->
throw error if error
我正在 node 中尝试这个(使用 coffee 用于那些很棒的)。但是由于某种原因,当它运行时,它给了我一个错误:Error: Command failed: conq: repository access denied. deployment key is not associated with the requested repository.
不知道我做错了什么。如果我直接从命令行运行这些命令,一切似乎都正常。有什么想法吗?
【问题讨论】:
-
你有没有试过直接用
ssh复制这个,把git排除在外?尽管您不太可能从 Bitbucket 的服务器中获得任何有用的信息(从错误消息中我认为这是您正在使用的),但您应该看到“您可以使用 git 或 hg 连接到 Bitbucket。Shell 访问被禁用。”如果有效;不行的话可以试试ssh -v调试。 -
您可以尝试的另一件事是制作一个运行
exec ssh -v "$@"的包装shell 脚本并设置GIT_SSH环境变量,以便git 以详细模式运行SSH。然后你可以看到git是如何运行SSH的,这可能会给你一些线索。
标签: node.js command-line ssh-keys