Again With The Permission Denied Could Not Read From Remote Repository

Turn on Agent Forwarding for SSH when deploying by Capistrano to Digital Ocean servers

me@jaykilleen.com wrote this over 7 years ago and it was last updated almost 4 years ago.


← Back to the Posts

Seems like every time I go back to a server to push a Capistrano deploy I am on a new machine and I am constantly running into:

  Permission denied (publickey).
  Could not read from remote repository.

I then start Googling for AllowAgentForwarding and wind up on sites like Github Developers and am starting from scratch trying to get SSH keys back authenticated against Github again.

After going round in circles for about 15 mins I realise I have been here before and never documented how I fix it.

Well, now I am documenting it and hopefully can rid myself of constantly hitting this hurdle.

The answered was found on this Stackoverflow Question and involved:

  eval "$(ssh-agent -s)"
  ssh-add ~/.ssh/id_rsa

or ssh-add ~/.ssh/id_ed25519 if you are on the new ssh standard.

Basically it seems I was not persisting my ssh login to allow the AgentForwarding to push my credentials to the server. Or that is what I gather was happening.

So by turning on the ssh agent and then adding my current key I could then allow the agent to forward the key to the server.

I probably have that totally wrong but I think that makes sense and will probably allow me now to stop hitting this hurdle.

Similar


Nothing yet is similar!