Capistrano cannot read from remote repository

since this week, I have an issue when deploying my Rails app with Capistrano:

Permission denied (publickey).
DEBUG[4a3de544]     fatal: Could not read from remote repository.

I don’t understand this, since I’m able to push to my remote repository, but when I run the command:

ssh -vvv git@github.com

I’m seeing this error messages in the output:

Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/Users/acandael/.ssh/id_rsa" as a RSA1 public key

Does anyone know how to fix this?

Again, I don’t know why this is happening as previously I was able to deploy with Capitstrano without a problem.

anyone experience the same issue? How can I fix this?

thanks for your help,

Anthony

It means your id_rsa key is not registered as being authenticated with your git repo. Check to make sure that key is one of your valid keys for github.

If you keys do not match follow the steps here

https://help.github.com/articles/generating-ssh-keys

or add one of your current keys.

Hi Jared,

Ok, but then why can I do a push from my development machine to the remote repo?

I checked the github troubleshooting and ran the command to check that I can connect to the server:

ssh -vT git@github.com

the output I’m getting, seems like my id_rsa key is recognized:

...
Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/acandael/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
...

Also when I run:

ssh -T git@github.com

I’m getting the message:

Hi acandael! You've successfully authenticated, but GitHub does not provide shell access.

But it seems like there is a problem with the private key.

When I run:

ssh-add -l

I get:

The agent has no identities.

thanks for your help,

Anthony

phew, solved it. The problem was indeed that for some reason my key wasn’t added anymore to my ssh-agent (see my previous reply).

running these commands added the key to my ssh-agent:

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 6273
ssh-add ~/.ssh/id_rsa

now Capistrano is able to deploy my Rails app again.

Just curious now what caused my ssh-agent to be without identities. All I know, is that last week I executed some OS X updates, maybe that caused the problem. Not sure though.

greeting and thanks to Jared for putting me on the right track to fix this.

Anthony

No worries, glad you solved the issue.

I have found out this problem occurs everytime I close my terminal session.

So everythime I close my terminal session, I get this error when trying to deploy with Capistrano:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

With these commands I add an identity to my ssh-agent:

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 6273
ssh-add ~/.ssh/id_rsa
Identity added: /Users/username/.ssh/id_rsa (/Users/username/.ssh/id_rsa)

but apparantly these settings are lost when I close my terminal session.

Does anyone have an idea how I can make these settings permanent?

thanks for your help,

Anthony

1 Like

Try to use -k with ssh-add. e.g:
ssh-add -k ~/.ssh/id_rsa