ssh秘钥配置

生成秘钥

1
ssh-keygen -t rsa -f ~/.ssh/id_rsa.xxxx -C "xxx@gmail.com"

秘钥远程拷贝

1
ssh-copy-id -i ~/.ssh/id_rsa.xxxx git@x.x.x.x

指定秘钥测试

1
ssh -i ~/.ssh/id_rsa.xxxx git@xxxx

ssh多秘钥配置文件

1
vim ~/.ssh/config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Host *
ServerAliveInterval 60
#github
Host xxxx.com
HostName xxxx.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.xxxx
#gitee
Host 2222.com
HostName 2222.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

#gogs
Host x.x.x.x
HostName x.x.x.x
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.xxxx