Capistrano 部署 - 权限被拒绝

Capistrano deploy - Permission denied

我正在尝试使用 capistrano 部署我的应用程序,但我遇到了一些问题。我的机器是 ec2 amazon,我在本地有 .pem。我可以毫无问题地执行 ssh 和 运行 命令,但是对于 cap 生产部署,我收到以下错误:

     DEBUG [4f4633f7] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-hybrazil-production-ronanlopes.sh" ; /usr/bin/env git ls-remote --heads git@git@github.com:fneto/hybrazil.git )

 DEBUG [4f4633f7]   Permission denied (publickey).

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   fatal: Could not read from remote repository.

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   Please make sure you have the correct access rights

 DEBUG [4f4633f7]   

and the repository exists.

 DEBUG [4f4633f7]   

在我的 production/deploy.rb 上,我有这样的配置:

set :ssh_options, {
  keys: %w(/home/ronanlopes/Pems/hybrazil-impulso.pem ~/.ssh/id_rsa),
  forward_agent: true,
  auth_methods: %w(publickey)
}

有什么想法吗?提前致谢!

您可以将密钥添加到代理,使用命令:

ssh-add ~/.ssh/id_rsa

在您的代码中,您应该使用 ssh 密钥的完整路径,不使用 pem:

keys: %w(/home/user_name/.ssh/id_rsa)