SSH 管理多个Key文件

Posted by 浮生 on 03-30,2020

在 ~/.ssh 文件夹下面新建 config,指定key

Host xxx.xxx.xxx.xxx
	HostName xxx.xxx.xxx.xxx
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_gitlab
        User User1
    
Host xxx.xxx.xxx.xxx
        HostName xxx.xxx.xxx.xxx
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_github
        User User2

Host 可以是IP或者域名
HostNameHost
IdentityFile 对应的Key私钥
User 私钥对应的用户