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 的下载地址:请点这里

本文永久更新链接地址

相关内容