Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git Capistrano无法使用SSH提取存储库_Git_Ssh_Capistrano_Capistrano3_Bitbucket Server - Fatal编程技术网

Git Capistrano无法使用SSH提取存储库

Git Capistrano无法使用SSH提取存储库,git,ssh,capistrano,capistrano3,bitbucket-server,Git,Ssh,Capistrano,Capistrano3,Bitbucket Server,我遵循了以下程序: 创建SSH密钥 在Atlassian隐藏中启用SSH 为名为Capistrano的存储帐户添加了SSH密钥(Capistrano已使用用户名和密码成功连接到存储) 使用命令git clone测试SSH连接ssh://git@stash.domain.com:7999/project/repository.git,存储库已成功克隆 将Capistrano项目目录中的以下行更改为config/deploy.rb: set:repo\u url,'ssh://git@stash.

我遵循了以下程序:

  • 创建SSH密钥
  • 在Atlassian隐藏中启用SSH
  • 为名为Capistrano的存储帐户添加了SSH密钥(Capistrano已使用用户名和密码成功连接到存储)
  • 使用命令git clone测试SSH连接ssh://git@stash.domain.com:7999/project/repository.git,存储库已成功克隆
  • 将Capistrano项目目录中的以下行更改为
    config/deploy.rb
    set:repo\u url,'ssh://git@stash.domain.com:7999/project/repository.git'
问题在于,执行命令
cap production git:check
I会得到以下错误行,部署被取消:

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\u url,'ssh://git@stash.domain.com:7999/project/repository.git'
,但我收到了相同的错误。 有人通过SSH成功连接Capistrano到Stash吗?
你能建议我如何调试它吗?我希望避免在Capistrano配置文件中使用用户名和密码。

这是一个过于简单的答案,但我猜Capistrano选择了错误的密钥。我建议您检查部署用户的默认ssh密钥。因此,如果capistrano设置为使用
deployuser
登录服务器,请查看
deployuser
键拾取的内容。使用
ssh-T进行测试会很有帮助git@stash.domain.com-p 7999
看看有什么结果。

谢谢你的回答,@will。不幸的是,当我执行(用我的域更改字符串)命令
ssh-T时git@stash.domain.com:7999
我回来了:
ssh:无法解析主机名stash.domain.com:7999:名称或服务未知
ping stash.domain.com
工作正常,我想这是因为端口号被附加到域中。谢谢,@will_in_wi。原因是我添加了部署管理计算机(源)的密钥而不是部署系统(目标)的密钥来隐藏,因此它没有拾取任何密钥。使用您的命令,我能够调试、在生产服务器中创建SSH密钥并将它们添加到存储中。