STchaoL 2020-06-04
多个 ssh key 配置多个网站
ssh-keygen -t rsa -C "你的邮箱" -f ~/.ssh/id_rsa_one ssh-keygen -t rsa -C "你的邮箱" -f ~/.ssh/id_rsa_two # 不添加-f 参数 会默认将私钥保存在~/.ssh/id_rsa
vim ~/.ssh/config
Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_one # 默认使用的是id_rsa Host gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_two # 默认使用的是id_rsa Host ubuntu-1 HostName 192.168.0.91 Port 22 # ssh 访问端口 User root # 登陆用户 IdentityFile ~/.ssh/id_rsa
ssh -T ssh -T ssh ubuntu-1 # 类似登陆 ssh -p 22