首页 > 解决方案 > 使用 ssh-agent 设置 ssh 进行部署,问题遵循 capistranorb.com 的说明

问题描述

我正在尝试遵循 capistranorb.com 上有关身份验证和授权的文档,但他们使用 github,我使用 bitbucket。有一个地方我被卡住了,因为控制台的输出不同。

存在文章中描述的生产服务器上名为 deploy 的用户。我可以 ssh 进入他的帐户。bitbucket 中的 repo 设置正确。我的一位同事可以毫无问题地部署该项目,所以问题是我个人设置的密钥。我尝试按照https://capistranorb.com/documentation/getting-started/authentication-and-authorisation/上的说明进行操作。一步不行。

当我做

My-MacBook-Pro-2:myproject myuser$ git config remote.origin.url

输出是

https://MyBitbucketUser@bitbucket.org/myfirm/myproject.git

关于 capistranorb 的文章说它应该类似于

git@github.com:capistrano/rails3-bootstrap-devise-cancan.git

所以那里没有https,它说git@。

他们文档中的以下命令是

ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git'

现在当我做

ssh -A deploy@myproject.net 'git ls-remote https://MyBitbucketUser@bitbucket.org/myfirm/myproject.git'

我得到一个错误,如果我省略了这个https://位。

如果我包含 https://,我会收到错误“致命:无法读取‘ https://DcsMarionDickten@bitbucket.org ’的密码:没有这样的设备或地址”,如果不包含,我会收到“。 .. 似乎不是 git 存储库”。

我应该补充一点,我已经设置了 git 来推送到 bitbucket 而不会要求我输入密码,我已经将我的公钥添加到了帐户中,这似乎是有效的。

这里有什么问题?

(我也许应该补充一点,我正在寻找一个与我的同事使用 ssh-agent 转发 ssh 密钥授权这一事实相关的问题,并且我的密钥设置时没有密码,因为我不知道你需要一个.)

标签: bitbucketcapistranossh-agent

解决方案


ssh-agent 无法理解基于 HTTPS 的 URL。您需要指定一个 SSH URL,例如MyBitbucketUser@bitbucket.org:myfirm/myproject.git。(git@bitbucket.org:myfirm/myproject.git也可以,也可以ssh://MyBitbucketUser@bitbucket.org/myfirm/myproject.git。)


推荐阅读