1. 检查是否存在公钥
检查 id_rsa.pub 是否存在
$ ls ~/.ssh/
2. 不存在即生成新的key
$ ssh-keygen -t rsa -b 2048 -C"your_email@example.com"
3. 将key加到git
复制id_rsa.pub文件内容到git -> settings -> ssh keys
github上可以下命令测试
$ ssh -T git@github.com
4. 确认ssh-agent处于启用状态
不执行可能会有报错:sign_and_send_pubkey: signing failed: agent refused operation
$ eval "$(ssh-agent -s)"
$ ssh-add
5. 配置多个ssh公钥
https://www.cnblogs.com/yu-hailong/p/11458782.html
参考资料: