参考: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成功