4

我能够使用这些说明使用 Gitlab 设置 Virtualbox --> https://github.com/gitlabhq/gitlabhq/wiki/VirtualBox-Image。Web 界面工作得很好,我已经添加了我的主机公钥并创建了一个“测试”项目。但是,我无法推送到我的测试存储库,因为它在创建测试目录并执行“git init”后要求输入 git@33.33.33.10 的密码。我已经添加了我的密钥,并且网络界面工作正常。有什么想法可能是错的吗?

$ git remote add test git@33.33.33.10:test.git
$ git push -u test master
git@33.33.33.10's password: ...

我也尝试过,结果相同(2222 VM 端等于 22 主机端):

git remote add test ssh://git@localhost:2222/test.git
git push -u test master
git@localhost's password:...

不应该需要密码。我还将 'vagrant' 用户添加到 VM 上的 'git' 组。

我已经验证在 VM 上我能够正确收到以下预期结果:

vagrant@lucid32:~$ ssh -T git@localhost
hello rails, this is gitolite v2.2-11-g8c4d1aa running on git 1.7.0.4
the gitolite config gives you the following access:
     R   W  gitolite-admin
    @R_ @W_ testing

这是我的流浪文件:

Vagrant::Config.run do |config|
config.vm.box = "gitlab"
config.vm.network :hostonly, "33.33.33.10"
end

这与远程 git 推送到 virtualbox 有关。谢谢您的帮助!

4

4 回答 4

1

我在启动和运行 vagrant 机器时遇到了一些严重的问题。一方面,它不使用代码所期望的相同默认值(参见#1)。它使用 rvm (参见#3)

  1. vagrant VM 决定使用“vagrant”而不是“git”作为用户。
    所以你的 repo URL 真的是:
    ssh:// vagrant @localhost:2222/test.git

  2. 我添加了一个 ~/.ssh/config (chmod 600):
    Host *
    User vagrant
    IdentityFile ~/.ssh/id_rsa`

  3. 如果你通过了这个,你可能会得到一个关于“/usr/bin/env ruby​​ 找不到文件”的错误,因为你正在使用 vagrant,它使用 rvm。
    我必须做这两件事:

于 2013-07-10T12:58:49.157 回答
0

似乎您的密钥没有发送到虚拟机。您能否检查您的用户 .ssh 目录中是否有正确的 id_rsa 和 id_rsa.pub 文件。如果您在 Windows 上运行 vagrant(http://vagrantup.com/docs/getting-started/ssh.html) ,这可能会非常有问题

希望这会有所帮助。

于 2012-04-07T23:09:38.257 回答
0

我使用不在虚拟机中的 gitlabhq_install 脚本进行了全新安装,并且遇到了最初的相同问题。我能够创建一个项目并通过 Web 界面添加我的密钥,但根本无法推送到测试存储库。所以我通过运行“ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host”添加了我的用户(不是 gitlabhq 用户)公共 ssh 密钥并重新启动了 ssh。我仍然遇到同样的问题,所以我“sudo vim /home/git/.ssh/authorized_keys”并手动将使用上述命令添加的密钥复制到“#gitolite start/end”标签之间。在重置 ssh 之后,我才终于能够推动......现在我仍在摸不着头脑,但至少我猜它有效。

于 2012-04-09T19:59:13.900 回答
0

当我试图推送到 gitlab.com 时,我遇到了同样的问题:

git push gitlab mybranch

使用以下流浪代码进行推送

  config.vm.provision :shell, :name => "pushing to remote", :keep_color => true, :privileged => false, :inline => <<-SHELL
        ---snip---
        git push gitlab mybranch
        ---snip---
  SHELL

发生以下错误:

==> default: GitLab: The project you were looking for could not be found.
==> default: fatal: Could not read from remote repository.
==> default:
==> default: Please make sure you have the correct access rights
==> default: and the repository exists.

我的解决方案是将应该由 vagrant 执行的代码放在 shell 脚本中,并使用包裹在su

  config.vm.provision :shell, :name => "Workaround to run update-repo.sh as vagrant user", :keep_color => true, :privileged => true, :inline => <<-SHELL
    su - vagrant -c /home/vagrant/bin/push.sh
  SHELL
于 2016-10-07T13:11:45.040 回答