Capistrano and GitHub Private Repo – Permission denied (publickey)

五迷三道 提交于 2019-12-03 06:49:11

Today I found the root cause on MAC. My ssh key was not added to the authentication agent so the key was not forwarded. The solution was to execute the following command:

ssh-add ~/.ssh/id_dsa

(or ssh-add ~/.ssh/id_rsa if you use rsa key)

Bill Watts

Try adding the following line to your Capistrano script, this will explicitly tell Capistrano what key it should be using.

set :ssh_options, { 
  forward_agent: true, 
  paranoid: true, 
  keys: "~/.ssh/id_rsa" 
}
vdaubry

If you're still stuck I answered a similar question as yours here: SSH Agent Forwarding not working

Check if your key is added to the list of agent identities with ssh-add -L.

Similarly I could SSH from dev machine to the staging machine and also SSH from staging machine to github.com.

However cap deploy failed doing the git clone

Permission denied (publickey).

however the git ls-remote worked which is strange.

If I added this to my config on the staging machine it works

Host github.com 
    Hostname github.com 
    IdentityFile ~/.ssh/git 
    User git
jasmo2

for me the only way it has deploy was:

adding the local id_rsa to the server cat ~/.ssh/github_rsa.pub | ssh -i /Users/jasmo2/Documents/AWS-keypair/designmatch.pem ubuntu@52.37.202.32 "cat >> .ssh/authorized_keys"

after typing the command. Is preferable to set the set :ssh_options. Then set :use_sudo, true on the deploy.rb file. Finally instal

  • On the server :

sudo apt-get install libpq-dev gem install pg -v '0.18.4'

  • On the deploy.rb (local):

desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do execute :mkdir, '-p', "#{ release_path }/tmp" execute :touch, release_path.join('tmp/restart.txt') end end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!