Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
602 views
in Technique[技术] by (71.8m points)

git - 使用Git时如何解决权限被拒绝(公钥)错误?(How to solve Permission denied (publickey) error when using Git?)

I'm on Mac Snow Leopard and I just installed git .

(我在Mac Snow Leopard上,并且刚刚安装了git 。)

I just tried

(我刚试过)

git clone [email protected]: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.

(我也尝试过使用ssh-keygen而不设置密码,但是仍然存在相同的错误。)

  ask by teepusink translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the user has not generated a ssh public/private key pair set before

(如果用户之前未生成ssh公用/专用密钥对)

This info is working on theChaw but can be applied to all other git repositories which support SSH pubkey authentications.

(该信息在theChaw上有效,但可以应用于支持SSH pubkey身份验证的所有其他git存储库。)

(See gitolite , gitlab or github for example.)

((例如,请参见gitolite ,gitlab或github。))

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.

(它可以使用DSA或RSA,因此基本上您设置的任何密钥都可以使用。)

On most systems you can use ssh-keygen.

(在大多数系统上,您可以使用ssh-keygen。)

  • First you'll want to cd into your .ssh directory.

    (首先,您需要CD进入.ssh目录。)

    Open up the terminal and run:

    (打开终端并运行:)

    cd ~/.ssh && ssh-keygen

  • Next you need to copy this to your clipboard.

    (接下来,您需要将此复制到剪贴板。)

    • On OS X run: cat id_rsa.pub | pbcopy

      (在OS X上运行: cat id_rsa.pub | pbcopy) cat id_rsa.pub | pbcopy

    • On Linux run: cat id_rsa.pub | xclip

      (在Linux上运行: cat id_rsa.pub | xclip) cat id_rsa.pub | xclip

    • On Windows (via Cygwin/Git Bash) run: cat id_rsa.pub | clip

      (在Windows上(通过Cygwin / Git Bash)运行: cat id_rsa.pub | clip) cat id_rsa.pub | clip

  • Add your key to your account via the website.

    (通过网站将密钥添加到您的帐户。)

  • Finally setup your .gitconfig.

    (最后设置您的.gitconfig。)

    • 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)

      (git config --global user.email bob@... (不要忘记重新启动命令行以确保重新加载了配置))

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) -

(有关更多信息, 参见https://help.github.com/articles/generating-ssh-keys (感谢@Lee Whitney)-)

If the user has generated a ssh public/private key pair set before

(如果用户之前已生成ssh公用/专用密钥对)

  • check which key have been authorized on your github or gitlab account settings

    (检查您的github或gitlab帐户设置中已授权的密钥)

  • tells which corresponding private key must be associated from your local computer

    (告诉您必须从本地计算机关联哪个对应的私钥)

eval $(ssh-agent -s)

tell where the keys are located

(告诉钥匙在哪里)

ssh-add ~/.ssh/id_rsa


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...