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 "your_email@example.com"
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建立個人技術部落格圖文詳解
GitHub 使用教程圖文詳解
Git 標籤管理詳解
Git 分支管理詳解
Git 遠程倉庫詳解
Git 本地倉庫(Repository)詳解
Git 伺服器搭建與用戶端安裝
Git 概述
分享實用的GitHub 使用教程
GitHub 的詳細介紹:請點這裡
GitHub 的:請點這裡
本文永久更新連結地址: