Capistrano无法使用SSH拉取Stash存储库

时间:2015-06-04 12:04:54

标签: git ssh capistrano capistrano3 bitbucket-server

我遵循以下程序:

  • 创建了SSH密钥;
  • 在Atlassian Stash中启用SSH;
  • 为名为Capistrano的Stash帐户添加了SSH密钥(已由Capistrano用于使用用户名和密码成功连接到Stash)
  • 使用命令git clone ssh://git@stash.domain.com:7999/project/repository.git测试了SSH连接,并成功克隆了存储库;
  • 将以下行更改为Capistrano项目目录中的config/deploy.rbset :repo_url, 'ssh://git@stash.domain.com:7999/project/repository.git'

问题是执行命令cap production git:check我得到以下错误行并取消部署:

INFO [8b21e06e] Running /usr/bin/env mkdir -p /tmp/capistrano_project_name/ as deploy@host.domain.com
DEBUG [8b21e06e] Command: /usr/bin/env mkdir -p /tmp/capistrano_project_name/
INFO [8b21e06e] Finished in 0.292 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/capistrano_project_name/git-ssh.sh 0.0%
INFO Uploading /tmp/capistrano_project_name/git-ssh.sh 100.0%
INFO [376577ce] Running /usr/bin/env chmod +x /tmp/capistrano_project_name/git-ssh.sh as deploy@host.domain.com
DEBUG [376577ce] Command: /usr/bin/env chmod +x /tmp/capistrano_project_name/git-ssh.sh
INFO [376577ce] Finished in 0.036 seconds with exit status 0 (successful).
INFO [2ed5c706] Running /usr/bin/env git ls-remote --heads ssh://git@stash.domain.com:7999/project/repository.git as deploy@host.domain.com
DEBUG [2ed5c706] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/capistrano_project_name/git-ssh.sh /usr/bin/env git ls-remote --heads ssh://git@stash.domain.com:7999/project/repository.git )
DEBUG [2ed5c706]        Permission denied (publickey).
DEBUG [2ed5c706]        fatal: Could not read from remote repository.
DEBUG [2ed5c706]
DEBUG [2ed5c706]        Please make sure you have the correct access rights
DEBUG [2ed5c706]        and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
Exception while executing as deploy@host.domain.com: git exit status: 128
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Tasks: TOP => git:check
(See full trace by running task with --trace)

我已经尝试将变量简单地更改为set :repo_url, 'ssh://git@stash.domain.com:7999/project/repository.git',但我收到了同样的错误。 有没有人通过SSH成功​​将Capistrano连接到Stash? 你能建议我如何调试吗?我想避免在我的Capistrano配置文件中使用用户名和密码。

1 个答案:

答案 0 :(得分:2)

一个简单的答案,但我猜Capistrano正在拿错钥匙。我建议您检查部署用户的默认ssh密钥。因此,如果将capistrano设置为使用deployuser登录服务器,请查看deployuser选择的密钥。使用ssh -T git@stash.domain.com -p 7999进行测试并查看返回的内容会很有帮助。