Capistrano and GitHub Private Repo – Permission denied (publickey)

前端 未结 6 1661
栀梦
栀梦 2021-02-09 01:31

I\'ve inherited a Rails project, hosted on Linode.

The previous developer was using a BitBucket repository, along with Capistrano for deployments.

I\'ve since

相关标签:
6条回答
  • 2021-02-09 02:01

    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.

    0 讨论(0)
  • 2021-02-09 02:02

    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

    0 讨论(0)
  • 2021-02-09 02:03

    Note you will also get this error if the deployment server has no disk space!

    0 讨论(0)
  • 2021-02-09 02:16

    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)

    To remove all the ssh keys added to agent

    ssh-add -D
    
    0 讨论(0)
  • 2021-02-09 02:19

    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" 
    }
    
    0 讨论(0)
  • 2021-02-09 02:20

    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
    
    0 讨论(0)
提交回复
热议问题