使用 bitbucket 部署 Capistrano - 权限被拒绝(公钥)

Capistrano deploy with bitbucket - Permission denied (publickey)

将 public 键添加到 bitbucket 帐户后,ssh -T git@bitbucket.org returns(在 windows 中):

The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 65:8c:1b:f2:6f:91:6b:5c:3b:ec:4a:46:46:74:7z:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org' (RSA) to the list of known hosts.
logged in as myusername.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

我们确认 bitbucket.org 已添加到 known_hostscap deploy命令returns:

Host key verification failed.
fatal: The remote end hung up unexpectedly

我们在 deploy.rb 文件中添加了以下两行:

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

现在cap deployreturns错误:

 Permission denied (publickey).

密钥不受密码保护。如果key被bitbucket接受了(ssh -T returns right info),为什么还会出现Permission denied.

的错误

您是否在远程服务器上运行 ssh -T git@bitbucket.org 命令,并在那里确认过?我刚刚检查了我使用 Capistrano 部署到的 Linux 服务器,并且 bitbucket.org 列在部署用户的 .ssh/known_hosts 文件中(它被散列,但 ssh-keygen -F bitbucket.org 显示它) .

Capistrano 通过 SSH 连接到远程服务器,然后 运行 从那里 git 签出。它需要连接到 Bitbucket 的权限,尽管访问权限是通过 :forward_agent 选项从源计算机授予的。