github-SSH key,Key is already in use

当尝试将相同的SSH Key添加到多个GitHub账户时遇到'Key is already in use'错误。按照GitHub文档,解决方案是创建新的SSH Key,如ssh-keygen -t rsa -C 'xxxxxx.com' -f ~/.ssh/id_rsa_github,并使用ssh-add添加到ssh-agent。验证成功后,将新密钥添加到GitHub账户,以便在不同仓库中使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:Managing deploy keys - GitHub Docs

很久注册过几个github账号,但是添加sshkey的时候,报错: Key is already in use

github文档也有过这样的描述

GitHub - Key is already in use

When attempting to add a deployment key to a GitHub repository, such as in the case of needing access for a submodule, or fetching remote dependencies within your build pipeline, you may run into the following error:

Key is already in use

This is because your DeployHQ project's public key has already been added to GitHub, most likely as the deployment key for the main repository you're trying to deploy.

Github does have a restriction that only allows a deployment key to be used on a single repository, but they offer a solution whereby you can create a machine (non-human) user and assign the deployment key to that user, which will then be given access to multiple Github repositories.

同一个SSH key在不同的账号添加不允许

解决方案:

创建其他的SSH key

命令:ssh-keygen -t rsa -C 'xxxxxx.com' -f ~/.ssh/id_rsa_github

一定要注意跟原来的密钥的命名区别id_rsa、id_rsa_github

一直enter就可以了

ssh-add id_rsa_github

ssh-add id_rsa

验证是否成功:

 ssh -T git@github.com

出现:Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

则为成功

 cat id_rsa_github.pub 查看密钥

添加到ssh key中, 重新push成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值