I'm trying to deploy my git repo to my server. To make this work I first needed to setup ssh on my locale computer and on my server.
for bitbucket I followed https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html and for pm2 I followed https://keymetrics.io/2014/06/25/ecosystem-json-deploy-and-iterate-faster/
I created the pub/priv key on my own computer and on my server. The connection now works since I can login to the server without entering a password. For the server I followed the exact same steps, but every time I reconnect to the server I got the error
Agent admitted failure to sign using the key.
I figured out that the ssh-agent was offline everytime I reconnected and therefore ssh-add -l
wouldn't print any result. I now added at the end of .bashrc
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Which seems to work, but always prompts me for the passphrase of .ssh/id_rsa
which probably is the reason why a pm2 deploy production setup
from my locale machine returns:
Agent admitted failure to sign using the key.
Cloning into '/home/myuser/myproject/source'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
failed to clone
has anyone an idea what I did wrong?
edit: I found this great answer: https://unix.stackexchange.com/a/90869 I decided to download keychain and added
eval `keychain --eval id_rsa`
instead of the old 2 commands to my .bashrc
. Now I can login to my server without any warning or error and ssh-add -l
displays my key correctly. but on my locale machine the pm2
command throws exactly the same error. Can the problem be somewhere else?
SOLUTION
I just redid the whole process with the same result. Finally I added the eval
keychain --eval id_rsa`` line at the top of my .bashrc
file. Now cloning works perfectly. I'm still not sure why the position within the file matters, but anyway.. it works