git的ssh认证添加方法

1 生成ssh公私钥对

ssh-keygen -t rsa

2 把公钥(~/.ssh/id_rsa.pub)用记事本打开,复制所有内容到gitlab的ssh的key中。

3 给主机添加私钥的身份。

ssh-add   ~/.ssh/id_rsa

如果没有3步的话,会提示Agent admitted failure to sign using the key的报错

4 从gitlab里clone代码

git clone [email protected]:dongzy/helloworld.git

直接用git做用户名就可以。

猜你喜欢

转载自blog.csdn.net/dong_beijing/article/details/82147952