美文网首页日常记录
Git For Windows 设置SSH公钥

Git For Windows 设置SSH公钥

作者: FinalException | 来源:发表于2020-03-28 10:27 被阅读0次

Git For Windows在每次提交代码的时候都需要输入用户名和密码,为了节省时间和精力,我们应该设置一个SSH公钥,这样就不用每次输入用户名和密码了。

具体步骤如下:

1、生成ssh密钥

cd ~/.ssh

使用 ssh-keygen 生成密钥

ssh-keygen -t rsa -C "your_email@example.com"

后面的三次输入均可使用默认值,Enter回车跳过

密钥生成成功

Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxx your_email@example.com
# 查看公钥,复制备用
cat id_rsa.pub
ssh-rsa xxxxxxxxxxxxxx_your public rsa_xxxxxxxxxxxxxxxxxxxxxxxxx  your_email@example.com

2、设置Git项目的ssh公钥,我这边是在Gitee上

注意:若此处设置错误,后面push代码到远程仓库时会提示没有正确的访问权限

接着上面的添加公钥:


3、设置代码远程提交URL

\color{red}{若有其他Gitee上项目也需要使用SSH免密操作,移步至对应项目的.git所在目录下,将该项目的远程地址设为对应的ssh地址即可}

下面这种Markdown语法,简书竟然不支持,目前用的这种语法:$\color{red}{红色字体内容} 显示不是很友好,只能勉强用了

<font color=#FF0000>若有其他Gitee上项目也需要使用SSH免密操作,移步至对应项目的.git所在目录下,将该项目的远程地址设为对应的ssh地址即可</font>


4、提交代码

省略git addgit commit等操作

已经不需要再输入用户名和密码了,至此Git For Windows 设置SSH公钥的操作就完成了,又能省点时间愉快的工(mo)作(yu)了。

相关文章

网友评论

    本文标题:Git For Windows 设置SSH公钥

    本文链接:https://www.haomeiwen.com/subject/kqljuhtx.html