Github 訪問時出現Permission denied (public key)

一. 發現問題:

  使用 git clone 命令時出現Permission denied (public key) 。git

二. 解決問題:

  1、首先嚐試從新添加之前生成的key,添加屢次,仍然不起做用。github

  2、使用命令 ssh -v git@github.com測試,最後幾行結果以下:   ssh

    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Trying private key: /home/gr/.ssh/id_rsa
    debug1: Trying private key: /home/gr/.ssh/id_dsa
    debug1: Trying private key: /home/gr/.ssh/id_ecdsa
    debug1: No more authentication methods to try.
    Permission denied (publickey).測試

  3、分析:嘗試了3個private key,但都沒有成功,最後是致使Permission denied.ui

  4、查看個人密鑰, ls ~/.ssh/ :spa

    bajie  bajie.pub  known_hosts    debug

  五、發現個人id_rsa文件我命令爲bajie, 因此根本沒有使用它。同時能夠使用以下命令查看密鑰列表:rpc

    ssh-add -lget

  六、上面命令的密鑰列表爲空,因此要添加個人密鑰,使用命令:it

    gr@grpc:~/workspace/git/home$ ssh-add ~/.ssh/bajie

    Enter passphrase for /home/gr/.ssh/bajie:
    Identity added: /home/gr/.ssh/bajie (/home/gr/.ssh/bajie)

  七、再次查看,以下,添加成功:

    gr@grpc:~/workspace/git/home$ ssh-add -l

    2048 63:c5:d8:6c:a0:0c:a8:9c:26:d8:f8:95:de:29:04:eb /home/gr/.ssh/bajie (RSA)

  8、再使用ssh -v git@github.com測試鏈接,能夠看到驗證經過:

    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /home/gr/.ssh/bajie
    debug1: Server accepts key: pkalg ssh-rsa blen 279
    debug1: Authentication succeeded (publickey).
    Authenticated to github.com ([192.30.252.129]:22).

  9、最後git clone項目成功。

 

  歡迎訪問個人我的主頁: www.forgerui.tk

相關文章
相關標籤/搜索