0

我在同一个 VPS 服务器上构建了 gitosis 服务器和 stage 服务器。在我的本地机器或阶段服务器中从 gitosis 克隆存储库运行良好。但是cap deploy在本地机器上总是要求我输入如下密码,我不知道是哪个密码,我尝试了每个密码都不起作用。

而且我知道可以使用 复制本地存储库deploy_via: copy,但我更喜欢为其他项目构建一个 gitosis 服务器。

有任何想法吗?谢谢。

环境

gitosis 和阶段服务器 ip:(106.187.xxx.xxx出于安全原因屏蔽一些数字)

日志

  * executing `deploy'
    triggering before callbacks for `deploy'
  * executing `check:revision'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote gitosis@106.187.xxx.xxx:foo_project.git master"
    command finished in 1105ms
  * executing "if [ -d /home/deployer/apps/railsapp/shared/cached-copy ]; then cd /home/deployer/apps/railsapp/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 07827de89355c5366c4511ee22fdd9c68a31b0be && git clean -q -d -x -f; else git clone -q gitosis@106.187.xxx.xxx:foo_project.git /home/deployer/apps/railsapp/shared/cached-copy && cd /home/deployer/apps/railsapp/shared/cached-copy && git checkout -q -b deploy 07827de89355c5366c4511ee22fdd9c68a31b0be; fi"
    servers: ["106.187.xxx.xxx"]
    [106.187.xxx.xxx] executing command
 ** [106.187.xxx.xxx :: out] Password:
Password: 
 ** [106.187.xxx.xxx :: out]
 ** [106.187.xxx.xxx :: out] Password:
Password: 
 ** [106.187.xxx.xxx :: out]
 ** [106.187.xxx.xxx :: out] Password:
Password: 
 ** [106.187.xxx.xxx :: out]
 ** [106.187.xxx.xxx :: out] Permission denied (publickey,keyboard-interactive).
 ** [106.187.xxx.xxx :: out] fatal: The remote end hung up unexpectedly

部署.rb

server "106.187.xxx.xxx", :web, :app, :db, primary: true

set :application, "railsapp"
set :user, "deployer"
set :local_user, "joshchang"
set :deploy_to, "/home/#{user}/apps/#{application}"

set :use_sudo, false
set :rails_env, "stage"

set :scm, "git"
set :repository, "gitosis@106.187.xxx.xxx:foo_project.git"
set :deploy_via, :remote_cache
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true
4

1 回答 1

0

git抱歉,这个问题有点难以理解,但是在 capistrano中有两种使用方法。首先是授予服务器直接访问 git 存储库的权限;例如,在 GitHub 上,您可以选择安装“部署密钥”——需要访问的服务器的公钥。所以检查gitosis是否有这个选项。

但在你做之前,考虑另一种方法,即通过执行部署的用户的 git 授权,所以当你部署时,你作为自己拉,而不是指示服务器这样做。每种方法都有利有弊,但我认为从长远来看,第二种方法更容易管理。

要使用第二种方法,部署人员(运行 capistrano)的机器需要 1)ssh-agent运行,并且 2)需要用于ssh-add授权ssh-agent使用您的公钥——它非常安全,一旦你设置好了,它是透明的。

当你使用第二种方法时,对 git 的访问将与本地相同,因此不应提示输入密码。否则,您的设置deploy.rb就可以了。

于 2012-11-19T19:21:50.813 回答