管理多个 GIT 个 ssh 密钥
Managing multiple GIT ssh keys
最近在同一台计算机上维护太多 SSH 密钥时遇到一些问题。
- 我在我的计算机中为用户 A(公司)和用户 B(个人)创建了两个 SSH 密钥。这两个 ID 都是使用不同的电子邮件 ID 创建的
- 我能够拉取和推送 UserA 的代码更改
但是 UserB 是我推送代码时遇到问题的地方。
- 我能够提取 UserB 的代码(其中 repo 与 UserA 不同)
推送代码时出现以下错误
ERROR: Permission to UserB/xxxxxx.git denied to UserA.
Please make sure you have the correct access rights
and the repository exists. ```
我觉得有点奇怪。有人可以帮我吗?
从 Git 2.3.0 开始,您可以使用以下命令
GIT_SSH_COMMAND='ssh -i private_key_file' git clone user@host:repo.git
已解决!!
使用以下 link、
为个人和工作创建 Gitconfig
https://medium.com/@trionkidnapper/ssh-keys-with-multiple-github-accounts-c67db56f191e
有时您会遇到存储在 ssh-agent 中的密钥过多的问题。
然后服务器在提供太多密钥后拒绝连接。
这可以通过强制 ssh 只使用一个特定的密钥来解决。
GIT_SSH_COMMAND='ssh -o IdentityAgent=none -i private_key_file' git <cmd>
最近在同一台计算机上维护太多 SSH 密钥时遇到一些问题。
- 我在我的计算机中为用户 A(公司)和用户 B(个人)创建了两个 SSH 密钥。这两个 ID 都是使用不同的电子邮件 ID 创建的
- 我能够拉取和推送 UserA 的代码更改
但是 UserB 是我推送代码时遇到问题的地方。
- 我能够提取 UserB 的代码(其中 repo 与 UserA 不同)
推送代码时出现以下错误
ERROR: Permission to UserB/xxxxxx.git denied to UserA.
Please make sure you have the correct access rights and the repository exists. ```
我觉得有点奇怪。有人可以帮我吗?
从 Git 2.3.0 开始,您可以使用以下命令
GIT_SSH_COMMAND='ssh -i private_key_file' git clone user@host:repo.git
已解决!!
使用以下 link、
为个人和工作创建 Gitconfighttps://medium.com/@trionkidnapper/ssh-keys-with-multiple-github-accounts-c67db56f191e
有时您会遇到存储在 ssh-agent 中的密钥过多的问题。
然后服务器在提供太多密钥后拒绝连接。
这可以通过强制 ssh 只使用一个特定的密钥来解决。
GIT_SSH_COMMAND='ssh -o IdentityAgent=none -i private_key_file' git <cmd>