无玄 發表於 2020-9-24 22:52:00

Gitee 怎样生成公钥?

<p></p><div class="toc"><div class="toc-container-header">目录</div><ul><li>ssh-keygen 不是内部或外部命令解决办法!<ul><li>解决办法一、设置环境变量</li><li>解决办法二、ssh.exe 根目录下执行命令</li></ul></li><li>生成/添加SSH公钥<ul><li>按照提示完成三次回车,即可生成 ssh key。</li><li>使用文本编辑器打开将KEY添加</li><li>添加后,在终端(Terminal)中输入 ssh -T git@gitee.com</li></ul></li></ul></div><p></p>
<h2 id="ssh-keygen-不是内部或外部命令解决办法">ssh-keygen 不是内部或外部命令解决办法!</h2>
<pre><code>Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\dphudy&gt;ssh-keygen -t rsa -C "2921832035@qq.com"
'ssh-keygen' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
</code></pre>
<h3 id="解决办法一设置环境变量">解决办法一、设置环境变量</h3>
<p>参考:https://www.cnblogs.com/e0yu/p/8508009.html<br>
Git安装路径 D:\Program Files\Git\usr\bin<br>
设置完成<br>
结果:重新执行失败,可能需要重启变量才会生效或者路径设置错误。<br>
<img src="https://img2020.cnblogs.com/blog/1372846/202009/1372846-20200924220443254-789591209.png" alt="" loading="lazy"></p>
<h3 id="解决办法二sshexe-根目录下执行命令">解决办法二、ssh.exe 根目录下执行命令</h3>
<pre><code>C:\Users\dphudy&gt; cd D:\Program Files\Git\usr\bin

C:\Users\dphudy&gt;D:

D:\Program Files\Git\usr\bin&gt;ssh-keygen -t rsa -C "2921832035@qq.com";
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dphudy/.ssh/id_rsa):
</code></pre>
<h2 id="生成添加ssh公钥">生成/添加SSH公钥</h2>
<h3 id="按照提示完成三次回车即可生成-ssh-key">按照提示完成三次回车,即可生成 ssh key。</h3>
<pre><code>D:\Program Files\Git\usr\bin&gt;ssh-keygen -t rsa -C "2921832035@qq.com";
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dphudy/.ssh/id_rsa):
Created directory '/c/Users/dphudy/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/dphudy/.ssh/id_rsa
Your public key has been saved in /c/Users/dphudy/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Mcook4KNWm5Sge+PUQuVv4q0bR7bvZwlwBCLEFBJHhE 2921832035@qq.com;
The key's randomart image is:
+-------+
|=+E+.            |
| +.o +         |
|. + =   o      |
|.+ + * . o       |
|+ X o * S      |
|.* = . o         |
|o * o . . .      |
| + B.= o +       |
|+o* . =.       |
+---------+

</code></pre>
<h3 id="使用文本编辑器打开将key添加">使用文本编辑器打开将KEY添加</h3>
<p><img src="https://img2020.cnblogs.com/blog/1372846/202009/1372846-20200924223051423-768210249.png" alt="" loading="lazy"></p>
<h3 id="添加后在终端terminal中输入-ssh--t-gitgiteecom">添加后,在终端(Terminal)中输入 ssh -T git@gitee.com</h3>
<pre><code>dphudy@dp071708004 MINGW64 ~
$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no/)? yes
Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
Hi 小岳! You've successfully authenticated, but GITEE.COM does not provide shell access.
</code></pre>
<p>首次使用需要确认并添加主机到本机SSH可信列表。若返回 Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. 内容,则证明添加成功。<br>
参考帮助中心:https://gitee.com/help/articles/4181#article-header0</p>


</div>
<div id="MySignature" role="contentinfo">
    <br/>
作者:燃烧的竹子
<br/>
出处:https://www.cnblogs.com/HittheRoad/
<br/>
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.<br><br>
来源:https://www.cnblogs.com/HittheRoad/p/13727009.html
頁: [1]
查看完整版本: Gitee 怎样生成公钥?