git设置SSH秘钥
1. 设置全局变量
###设置你的用户名
git config --gloabl user.name "Your Name"
###设置你的邮箱
git config --global user.email your_email@example.com
###查看配置结果
git config --list
2. 生成公钥和密钥
###生成密钥,如果已有,可选覆盖y, 剩余一路回车(设置ssh的连接访问密码,建议不写),
ssh-keygen -t rsa -C hhhh@qq.com
##查看公钥
cat ~/.ssh/id_rsa.pub
3. git服务上设置公钥
找到设置,增加SSH秘钥,把之前查看的粘贴到这里
4.测试是否可行
不要连接,直接clone,因为有些时候估摸不准地址
例如 git clone ssh://git@gitlab.XXX:application-one/xxxxxxxxxxx.git
如果clone报错就估摸着呵呵呵了
5.如果报错,各种调试方式
看网上的方式,我也不知道对不对
报错:Permission denied (publickey,
用:
ssh-agent –s
ssh-add ~/.ssh/id_rsa