同一远程主机上git的不同RSA密钥
当连接到此主机上的不同git存储库时,我希望对同一主机使用不同的rsa密钥 例如,我在example.com上有两个git存储库:同一远程主机上git的不同RSA密钥,git,rsa,Git,Rsa,当连接到此主机上的不同git存储库时,我希望对同一主机使用不同的rsa密钥 例如,我在example.com上有两个git存储库: git@git.example.com:rep1 及 使用两个不同RSA密钥的典型方法是针对不同的主机 ~/.ssh/config: Hostname example.com User git IdentityFile ~/.ssh/key1 这对我不起作用,因为两个存储库托管在同一台主机上 您有什么建议吗?您可以使用Host关键字: Host host1 Ho
git@git.example.com:rep1
及
使用两个不同RSA密钥的典型方法是针对不同的主机
~/.ssh/config:
Hostname example.com
User git
IdentityFile ~/.ssh/key1
这对我不起作用,因为两个存储库托管在同一台主机上
您有什么建议吗?您可以使用
Host
关键字:
Host host1
HostName git.example.com
User git
IdentityFile ~/.ssh/key1
Host host2
HostName git.example.com
User git
IdentityFile ~/.ssh/key2
然后使用
ssh host1
或ssh host2
而不是使用完整的主机名。好建议,但我会缩进属于给定host
定义的所有行,以便更清楚地找到答案,但是我现在如何添加git remote?@NilsZiehn:Usessh://host1/rep1
和ssh://host2/rep2
作为URL。(我更改了主机标识符以使其更具可读性)。
Host host1
HostName git.example.com
User git
IdentityFile ~/.ssh/key1
Host host2
HostName git.example.com
User git
IdentityFile ~/.ssh/key2