ssh的使用和配置
检查已经存在的ssh keys
1  | ls -al ~/.ssh  | 
新建ssh key
1  | ssh-keygen -t rsa -b 4096 -C "your_email@example.com"  | 
使用ssh-agent来管理ssh key
1  | eval $(ssh-agent -s)  | 
修改ssh key的密码
1  | ssh-keygen -f ~/.ssh/id_rsa -p  | 
配置不同的host使用不同的ssh
在~/.ssh文件夹下,新建config文件并写入下面的代码1
2
3
4
5
6
7
8
9
10
11
12
13
14Host xxx.com
  HostName 192.168.1.1
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/sampwood_id_rsa
  IdentitiesOnly yes
Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/sampwood_id_rsa
  IdentitiesOnly yes
参考
原文作者: Sampwood
原文链接: https://sampwood.github.io/2019/02/28/ssh的使用和配置/
许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议