在一台电脑上添加多个ssh key

1.创建新的ssh key

$ ssh-keygen -t rsa -C "[email protected]" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xxx/.ssh/id_rsa): 

设置文件名,注意这里要写绝对路径,如/home/xxx/.ssh/new_rsa
2. 将密钥添加到SSH agent中

$ ssh-add ~/.ssh/new_rsa

若显示权限问题,执行sudo chmod 600 ~/.ssh/new_rsa
ssh-add -l可以查看添加过的密钥
ssh-add -D可以删除密钥
3.查看密钥,并将密钥添加到git上

$ cat ~/.ssh/new_rsa.pub 

参考资料1
参考资料2

发布了30 篇原创文章 · 获赞 86 · 访问量 38万+

猜你喜欢

转载自blog.csdn.net/gongchenyu/article/details/84349809