
No more than code.
查看本地是否存在公钥 SSH-Key
cd .ssh ls -a
根据账户邮箱生成 SSH-Key
ssh-keygen -t rsa -C “邮箱”; 一路回车
id_rsa id_rsa.pub
查看SSH-Key
cat id_rsa.pub
创建配置文件 touch config
编辑 vim config
#网站的别名
Host github
#托管网站的域名
HostName github.com
#托管网站上的用户名
User Selenamona
#使用的密钥文件
IdentityFile ~/.ssh/id_rsa_github
#网站的别名
Host yxqiche
#托管网站的域名
HostName gitlab.yxqiche.com
#托管网站上的用户名
User madongxue
#使用的密钥文件
IdentityFile ~/.ssh/id_rsa
$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa_github
ssh-add
需要在 ssh-agent bash 后执行,选项 -D:删除ssh-agent中的所有密钥. -d:从ssh-agent中的删除密钥 -e pkcs11:删除PKCS#11共享库pkcs1提供的钥匙。 -s pkcs11:添加PKCS#11共享库pkcs1提供的钥匙。 -L:显示ssh-agent中的公钥 -l:显示ssh-agent中的密钥 -t life:对加载的密钥设置超时时间,超时ssh-agent将自动卸载密钥 -X:对ssh-agent进行解锁 -x:对ssh-agent进行加锁
例如查看ssh-agent中的密钥: ssh-add -l