是否有任何方法可以为每个克隆的存储库定义它应该使用哪个 SSH key 对的路径?
最佳答案
是的,您需要定义一个~/.ssh/config
文件,您可以在其中声明不同的ssh名称,以及要使用的公钥/私钥的自定义完整路径名。
Host AHostName -- name you will use for the ssh address
User gituser
Hostname SSH IP address
Port 1234 -- use this if you need custom ports
IdentityFile "path to your private ssh key"
从那里,存储库的 ssh URL 可以是:
AHostName:myrepo
另请参阅:
关于git - Mercurial 和 Git 自定义 SSH key 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12668278/