Git and ssh authorizating

2019-03-11 07:44发布

问题:

I can't login to github with generated ssh-keys. I've followed this manual: http://help.github.com/linux-key-setup but at step:

ssh git@github.com

I get:

Agent admitted failure to sign using the key. Permission denied (publickey).

What's wroing? And, of course, I'm adding my own user email.


Tried dsa-key, the same thing.

回答1:

From the troubleshooting guide:

Permission denied (publickey)

This is usually caused when ssh cannot find your keys. Make sure your key is in the default location, ~/.ssh. If you run ssh-keygen again and just press enter at all 3 prompts it will be placed here automatically. Then you can add the contents of id_rsa.pub to my github keys. If id_rsa.pub doesn’t work try id_dsa.pub. You might need to generate a new dsa key with ssh-keygen -t dsa if you just have an rsa key.

If you are still having problems and none of the above worked, you may have a blacklisted key from a debian open-ssh bug. you should update open-ssh and re-generate your keys.

So, just to check - are your keys available under ~/.ssh/ as id_rsa and id_rsa.pub or otherwise, are you specifying their use?



回答2:

I found this which helped me greatly http://playwithrubyandrails.blogspot.com/2011/04/process-for-deploying-app-on-heroku.html

ssh-add ~/.ssh/id_rsa solved my problem after generating the relevant keys



回答3:

After generating the ssh keys I executed the command listed below as suggested by jamesw.

$ ssh-add ~/.ssh/id_rsa

I entered my password. Then retried to clone the heroku repository. This time it worked fine.



回答4:

This is a ubuntu problem. Exporting "SSH_AUTH_SOCK=0" solved the problem for me. More details can be found at - https://bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/201786.



回答5:

I was able to get gitlab working thanks to this thread (I know that's not github).

I too found the answer by @jamesw to be correct.

I ended up having to delete my known_hosts file and recreate my ssh key with the same password as my gitlab account.

Then I did the ssh-add and did a git push -u origin master. Success!

Thanks for the help everyone.

UPDATE:
I decided to remake my ssh key without a password and ran into this error again.

This time, I was able to copy my old known_hosts to the new .ssh/ and simply run the ssh-add.



回答6:

Above Accepted solution did not work for me, but this worked http://ripan27.wordpress.com/2010/04/01/ssh-gitgithub-com-agent-admitted-failure-to-sign-using-the-key-permission-denied-publickey/



回答7:

This issue occurs mainly due to the following reasons :

  • The public and private key pair is wrong. You have to verify the key public key on the server/ your git account where you have placed the public key. Even a small space or tab will result in the error.
  • If you are sure your public key is correct, then check the format of public key in your ~/.ssh folder in your machine. For openssh you cannot use a public key in puttygen format and visa-versa. To change the format you can use the following command using your private key

    $ ssh-keygen -e -f ~/.ssh/id_rsa > ~/.ssh/id_rsa_com.pub
    $ ssh-keygen -i -f ~/.ssh/id_rsa_com.pub > ~/.ssh/id_rsa.pub

  • Finally check if you have added your keys to the ssh client in your system. You can do so by using the following commands

    $ eval "$(ssh-agent -s)"

    $ ssh-add



回答8:

Note that ssh-agent is per session (per terminal). Use ssh agent manager like keychain (see its documentation on how to set it up) to have access via any session (from any term).



回答9:

I encounterded same error when I copied id_rsa and idrsa.pub from another os. These files were 644 permission. So I changed it to 600. the error was fixed.



标签: git ssh github rsa