1. 程式人生 > >Git: Github提示Key is already use

Git: Github提示Key is already use

背景:在Github中為使用者新增SSH Key的時候報Key is already use,根據錯誤提示很顯然,所新增的SSH Key已經被其他賬號使用後,才會出現這個錯誤。現在有兩種解決辦法,第一,找到帳號刪除Key;第二,重新生成Key


找到使用該Key的帳號,在Github個人資訊中有SSH and GPG keys這一欄,管理著所有的SSH Keys,找到匹配的Key刪除,另外一個賬號就可以使用該Key了


重新生成SSH Key,僅需幾個簡單的步驟1.開啟終端2.輸入以下命令,並執行
$ ssh-keygen -t rsa -b 4096 -C "[email protected]

"
Creates a new ssh key, using the provided email as a labelGenerating public/private rsa key pair.

3.輸入需要儲存的檔名,同時儲存在預設的位置。我使用的是Mac,檔案儲存在.ssh資料夾下面,可以通過命令,cd ~/.ssh進入。Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
4.輸入密碼和確認密碼,可以跳過Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]


到這裡,SSH Key已經生成好了,在檔案在.ssh目錄下


5.SSH Key生成好後,需要新增到ssh-agent才能發揮效果,第一步檢查ssh-agent是否啟動,如果啟動可以看如下效果
$ eval "$(ssh-agent -s)"Agent pid 595666.新增到ssh-agent$ ssh-add ~/.ssh/id_rsa

 記得Github上也要新增對應的SSH Key,完工。哦!還有一件很重要的事情和大家分享,附上此文的Github官方文件,把原汁原味呈現給大家,https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

GitHub 教程系列文章: 

通過GitHub建立個人技術部落格圖文詳解  http://www.linuxidc.com/Linux/2015-02/114121.htm

GitHub 使用教程圖文詳解  http://www.linuxidc.com/Linux/2014-09/106230.htm 

Git 標籤管理詳解 http://www.linuxidc.com/Linux/2014-09/106231.htm 

Git 分支管理詳解 http://www.linuxidc.com/Linux/2014-09/106232.htm 

Git 遠端倉庫詳解 http://www.linuxidc.com/Linux/2014-09/106233.htm 

Git 本地倉庫(Repository)詳解 http://www.linuxidc.com/Linux/2014-09/106234.htm 

Git 伺服器搭建與客戶端安裝  http://www.linuxidc.com/Linux/2014-05/101830.htm 

Git 概述 http://www.linuxidc.com/Linux/2014-05/101829.htm 

分享實用的GitHub 使用教程 http://www.linuxidc.com/Linux/2014-04/100556.htm 

GitHub 的詳細介紹請點這裡 
GitHub 的下載地址請點這裡

本文永久更新連結地址http://www.linuxidc.com/Linux/2016-06/132089.htm