Permission denied (publickey)
I'm on Mac Snow Leopard and I just installed git.
I just tried
git clone git@thechaw.com:cakebook.git
but that gives me this error.
Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/` Permission denied (publickey). fatal: The remote end hung up unexpectedly
What am I missing?
I've also tried doing ssh-keygen
with no passphase but still same error.
This info is working on theChaw but can be applied to all other git repositories which support SSH pubkey authentications. (See gitolite, gitlab or github for example.)
First start by setting up your own public/private key pair set. This can use either DSA or RSA, so basically any key you setup will work. On most systems you can use ssh-keygen.
cd ~/.ssh && ssh-keygen
cat id_rsa.pub | pbcopy
cat id_rsa.pub | pbcopy
cat id_rsa.pub | xclip
cat id_rsa.pub | xclip
cat id_rsa.pub | clip
cat id_rsa.pub | clip
git config --global user.name "bob"
git config --global user.email bob@...
(don't forget to restart your command line to make sure the config is reloaded) Thats it you should be good to clone and checkout.
Further information can be found on https://help.github.com/articles/generating-ssh-keys (thanks to @Lee Whitney)
More extensive troubleshooting and even automated fixing can be done with:
ssh -vT git@github.com
Source: https://help.github.com/articles/error-permission-denied-publickey/
This error can happen when you are accessing the SSH URL (Read/Write) instead of Git Read-Only URL but you have no write access to that repo.
Sometimes you just want to clone your own repo, eg deploy to a server. In this case you actually only need READ-ONLY access. But since that's your own repo, GitHub may display SSH URL if that's your preference. In this situation, if your remote host's public key is not in your GitHub SSH Keys, your access will be denied, which is expected to happen .
An equivalent case is when you try cloning someone else's repo to which you have no write access with SSH URL.
In a word, if your intent is to clone-only a repo, use HTTPS URL ( https://github.com/{user_name}/{project_name}.git
) instead of SSH URL ( git@github.com:{user_name}/{project_name}.git
), which avoids (unnecessary) public key validation.
Update: GitHub is displaying HTTPS as the default protocol now and this move can probably reduce possible misuse of SSH URLs.
链接地址: http://www.djcxy.com/p/27060.html上一篇: 无法打开与身份验证代理的连接
下一篇: 权限被拒绝(公钥)