ssh

生成 ssh 秘钥

1
ssh-keygen -t rsa -m PEM -b 4096 -f 'file_name' -C "you_email@email.com"

当有多个 ssh 秘钥对 时,需要配置 ~/.ssh/config 来确保 ssh 可以正确解析

1
2
3
4
5
6
7
8
9
10
11
12
13
Host vpn
user root
hostname 8.8.8.8
Identityfile ~/.ssh/id_rsa_vpn

Host 8.8.8.8
user root
hostname 8.8.8.8
Identityfile ~/.ssh/id_rsa_vpn

Host github.com
IdentityFile ~/.ssh/id_rsa_github

其中的 Host user Identityfile 等 不区分大小写,具体细节在这里,也可以通过 man ssh_config 查看

其中 Identityfile 来指定对应的 ssh 的秘钥
如果按上述配置的话,则 ssh vpn == ssh root@8.8.8.8