在与代理的会话中选择 SSH 标识文件



我正在服务器中"尝试"这个:

# ~/.ssh/config
Host github.com
  IdentityFile xxxx

当我在服务器中执行时,我应该xxxx放入什么:

git clone git@github.com:myuser/myrepo.git

Git 在我的本地使用身份,而不是在服务器中使用身份,该身份位于~/.ssh/my_another_private_key_file中,不使用默认密钥~/.ssh/id_rsa

这应该放在你正在执行 git 克隆的机器上的 ~/.ssh/config 文件中:

Host github.com
  IdentityFile ~/.ssh/my_another_private_key_file

如果您在服务器上执行克隆并且my_another_private_key_file在本地,则可能需要将其添加到服务器上的~/.ssh/identity中,因此当您在那里进行ssh-add时,它会被添加到您的ssh代理进程中。

最新更新