首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chef git cookbook:如何修复克隆私有存储库时被拒绝的权限?

Chef git cookbook:如何修复克隆私有存储库时被拒绝的权限?
EN

Stack Overflow用户
提问于 2015-07-19 07:05:00
回答 1查看 1.1K关注 0票数 0

我有一个食谱,它使用deploy_key cookbook来生成部署密钥和git食谱来克隆私有的gitlab项目。

Chef总是说他已经成功地部署了密钥,并给了它们适当的权限。

但有时它工作得很好,有时会出现以下错误,我不知道为什么。

代码语言:javascript
复制
==> default: ================================================================================
==> default: Error executing action `sync` on resource 'git[/home/vagrant/webtest]'
==> default: ================================================================================
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '128'
==> default: ---- Begin output of git ls-remote "git@gitlab.example.com:qa/webtest.git" "HEAD" ----
==> default: Permission denied, please try again.
==> default: Permission denied, please try again.
==> default: Permission denied (publickey,password).
==> default: fatal: Could not read from remote repository.
==> default: Please make sure you have the correct access rights
==> default: and the repository exists.
==> default: ---- End output of git ls-remote "git@gitlab.example.com:qa/webtest.git" "HEAD" ----
==> default: Ran git ls-remote "git@gitlab.example.com:qa/webtest.git" "HEAD" returned 128

此外,如果chef无法克隆项目,并显示以下消息,则第二个配置(我已经为此尝试过vagrant provision )将正常工作(就像我将登录VM并手动克隆项目一样)。

我想有时候密钥不能及时部署..但根据厨师的输出,他们必须准备好了。

可能的问题是什么?

我正在部署密钥(每次部署都会使用gitlab project_id和token以如下方式生成新密钥):

代码语言:javascript
复制
deploy_key "my_project_deploy_key" do
    provider Chef::Provider::DeployKeyGitlab
    path "#{node['webtest']['home_dir']}/.ssh"
    credentials({
        :token => node['webtest']['gitlab']['token']
    })
    api_url "#{node['webtest']['gitlab']['api_scheme']}://#{node['webtest']['gitlab']['api_domain']}"
    repo  node['webtest']['gitlab']['project_id']
    owner node['webtest']['user']
    group node['webtest']['group']
    mode 00600
    action :add
end

我是这样克隆repo的:

代码语言:javascript
复制
git "#{node['webtest']['home_dir']}/webtest" do
    repository node['webtest']['git']['repo']
    checkout_branch node['webtest']['git']['branch']
    ssh_wrapper "#{node['webtest']['home_dir']}/.ssh/wrap-ssh4git.sh"
    user node['webtest']['user']
    group node['webtest']['group']
    enable_checkout false
    action :sync
end
EN

回答 1

Stack Overflow用户

发布于 2015-07-19 07:17:59

为了让这个示例正常工作,您需要让gitlab.example.com知道您的公钥,这样ssh就可以使用您的私钥进行连接。

方法各不相同,但是对于现代的Linux机器,ssh-copy-id可能更容易正确地复制您的公钥。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31496405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档