{"id":455,"date":"2021-06-13T18:25:59","date_gmt":"2021-06-13T10:25:59","guid":{"rendered":"http:\/\/moyisuiying.com\/?p=455"},"modified":"2021-06-13T18:25:59","modified_gmt":"2021-06-13T10:25:59","slug":"windows%e4%b8%8b-git%e9%85%8d%e7%bd%aegithub%e5%92%8cgitee-ssh-key%e5%af%86%e9%92%a5%e6%96%b9%e4%be%bf%e5%90%8c%e6%97%b6%e5%b0%86%e6%9c%ac%e5%9c%b0%e5%88%86%e6%94%af%e6%8e%a8%e9%80%81%e5%88%b0","status":"publish","type":"post","link":"http:\/\/moyisuiying.com\/index.php\/gitstudy\/455.html","title":{"rendered":"windows\u4e0b git\u914d\u7f6egithub\u548cgitee SSH-Key\u5bc6\u94a5\u65b9\u4fbf\u540c\u65f6\u5c06\u672c\u5730\u5206\u652f\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93"},"content":{"rendered":"\n<h2>1\u5148\u914d\u7f6egiteee\u7684SSH-Key<\/h2>\n\n\n\n<p>\u751f\u6210\u4e00\u4e2agitee\u7528\u7684SSH-Key\u5bc6\u94a5\uff1a\u8f93\u5165\u547d\u4ee4\uff1a\uff08gitee_id_rsa\u662f\u751f\u6210\u516c\u94a5\u7684\u540d\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh-keygen -t rsa -C '\u4f60\u7684\u90ae\u7bb1' -f ~\/.ssh\/gitee_id_rsa<\/code><\/pre>\n\n\n\n<p>\u70b9\u51fb\u4e09\u6b21\u56de\u8f66\uff0c\u8fd9\u91cc\u4ec0\u4e48\u4e5f\u4e0d\u7528\u586b\u3002<\/p>\n\n\n\n<h2>2.\u914d\u7f6egithub\u7684SSH-Key<\/h2>\n\n\n\n<p>\u751f\u6210\u4e00\u4e2agithub\u7528\u7684SSH-Key\u5bc6\u94a5\uff1a\u8f93\u5165\u547d\u4ee4\uff1a\uff08github_id_rsa\u662f\u751f\u6210\u516c\u94a5\u7684\u540d\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh-keygen -t rsa -b 4096 -C \"\u4f60\u7684\u90ae\u7bb1\" -f ~\/.ssh\/github_id_rsa<\/code><\/pre>\n\n\n\n<p>\u70b9\u51fb\u4e09\u6b21\u56de\u8f66\uff0c\u8fd9\u91cc\u4ec0\u4e48\u4e5f\u4e0d\u7528\u586b\u3002<\/p>\n\n\n\n<h3>2.1 \u5c06SSH\u5bc6\u94a5\u6dfb\u52a0\u5230 ssh-agent\uff0c\u8f93\u5165\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ eval $(ssh-agent -s)<\/code><\/pre>\n\n\n\n<p>\u8fd4\u56de\u7c7b\u4f3c\u8fd9\u6837\u7684\u4e1c\u897f<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&gt; Agent pid 595<\/p><\/blockquote>\n\n\n\n<h3>2.2\u5c06ssh\u5bc6\u94a5\u6dfb\u52a0\u5230github<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh-add ~\/.ssh\/github_id_rsa<\/code><\/pre>\n\n\n\n<h2>3\uff1a\u5728C:\\Users\\\u4f60\u7684\u7528\u6237\u540d.ssh\u76ee\u5f55\u4e0b\u53ef\u4ee5\u770b\u89c1\u5347\u7ea7\u7684\u5bc6\u94a5\u6587\u4ef6\uff0c\u5e76\u65b0\u5efa\u4e00\u4e2aconfig\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># gitee\nHost  gitee.com\nHostName   gitee.com\nPreferredAuthentications publickey\nIdentityFile ~\/.ssh\/gitee_id_rsa\n# github\nHost  github.com\nHostName  github.com\nPreferredAuthentications publickey\nIdentityFile ~\/.ssh\/github_id_rsa<\/code><\/pre>\n\n\n\n<h2>4.ssh\u5bc6\u94a5\u6dfb\u52a0\u5230gitee<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-add ~\/.ssh\/gitee_id_rsa<\/code><\/pre>\n\n\n\n<p>\u5728\u4efb\u4f55\u9875\u9762\u7684\u53f3\u4e0a\u89d2\uff0c\u5355\u51fb\u60a8\u7684\u4e2a\u4eba\u8d44\u6599\u7167\u7247-&gt;\u8bbe\u7f6e-&gt;\u5de6\u4fa7\u83dc\u5355\u680f\u627e\u5230SSH\u516c\u94a5-&gt;\u5c06C:\\Users\\\u4f60\u7684\u7528\u6237\u540d.ssh\u76ee\u5f55\u4e0bgitee_id_rsa.pub\u6587\u4ef6\u6253\u5f00\u590d\u5236\u91cc\u9762\u7684\u5185\u5bb9\u6dfb\u52a0\u5230\u5bc6\u94a5\uff08\u6709\u53ef\u80fd\u8f93\u5165\u5bc6\u7801\uff0c\u8f93\u5165\u5c31\u884c\uff09\u3002<\/p>\n\n\n\n<h2>5.ssh\u5bc6\u94a5\u6dfb\u52a0\u5230github<\/h2>\n\n\n\n<p>\u5728\u4efb\u4f55\u9875\u9762\u7684\u53f3\u4e0a\u89d2\uff0c\u5355\u51fb\u60a8\u7684\u4e2a\u4eba\u8d44\u6599\u7167\u7247\uff0c\u7136\u540e\u5355\u51fb Settings\uff08\u8bbe\u7f6e\uff09\u3002<\/p>\n\n\n\n<p>\u5728\u7528\u6237\u8bbe\u7f6e\u4fa7\u8fb9\u680f\u4e2d\uff0c\u5355\u51fb SSH and GPG keys\uff08SSH \u548c GPG \u5bc6\u94a5\uff09\u3002<\/p>\n\n\n\n<p>\u5355\u51fb New SSH key\uff08\u65b0 SSH \u5bc6\u94a5\uff09\u3002<\/p>\n\n\n\n<p>\u5728 \"Title\"\uff08\u6807\u9898\uff09\u5b57\u6bb5\u4e2d\uff0c\u4e3a\u65b0\u5bc6\u94a5\u6dfb\u52a0\u63cf\u8ff0\u6027\u6807\u7b7e\u3002 \u5c06C:\\Users\\\u4f60\u7684\u7528\u6237\u540d.ssh\u76ee\u5f55\u4e0bgithub_id_rsa.pub\u6587\u4ef6\u6253\u5f00\u590d\u5236\u91cc\u9762\u7684\u5185\u5bb9\u6dfb\u52a0\u5230\u5bc6\u94a5\u7c98\u8d34\u5230 \"Key\"\uff08\u5bc6\u94a5\uff09\u5b57\u6bb5\u3002<\/p>\n\n\n\n<p>\u5355\u51fb Add SSH key\uff08\u6dfb\u52a0 SSH \u5bc6\u94a5\uff09\u3002<\/p>\n\n\n\n<p>\u5982\u6709\u63d0\u793a\uff0c\u8bf7\u786e\u8ba4\u60a8\u7684 GitHub \u5bc6\u7801\u3002<\/p>\n\n\n\n<h2>6.\u7528ssh\u547d\u4ee4\u5206\u522b\u6d4b\u8bd5<\/h2>\n\n\n\n<h3>6.1 \u6d4b\u8bd5gitee<\/h3>\n\n\n\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh -T &#91;git@gitee.com](mailto:git@gitee.com)<\/code><\/pre>\n\n\n\n<p>\u82e5\u8fd4\u56de Hi XXX! You've successfully authenticated, but <a href=\"https:\/\/link.zhihu.com\/?target=http%3A\/\/Gitee.com\" target=\"_blank\"  rel=\"nofollow\" >\u7801\u4e91 Gitee \u2014 \u57fa\u4e8e Git \u7684\u4ee3\u7801\u6258\u7ba1\u548c\u7814\u53d1\u534f\u4f5c\u5e73\u53f0<\/a> does not provide shell access. \u5185\u5bb9\uff0c\u5219\u8bc1\u660e\u6dfb\u52a0\u6210\u529f\u3002<\/p>\n\n\n\n<h3>6.2 \u6d4b\u8bd5github<\/h3>\n\n\n\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh -T &#91;git@github.com](mailto:git@github.com)<\/code><\/pre>\n\n\n\n<p>\u60a8\u53ef\u80fd\u4f1a\u770b\u5230\u7c7b\u4f3c\u5982\u4e0b\u7684\u8b66\u544a\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&gt; The authenticity of host '<a href=\"https:\/\/link.zhihu.com\/?target=http%3A\/\/github.com\" target=\"_blank\"  rel=\"nofollow\" >Build software better, together<\/a> (IP ADDRESS)' can't be established.<br>&gt; RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.<br>&gt; Are you sure you want to continue connecting (yes\/no)?<\/p><\/blockquote>\n\n\n\n<p>\u6216\u7c7b\u4f3c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&gt; The authenticity of host '<a href=\"https:\/\/link.zhihu.com\/?target=http%3A\/\/github.com\" target=\"_blank\"  rel=\"nofollow\" >Build software better, together<\/a> (IP ADDRESS)' can't be established.<br>&gt; RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.<br>&gt; Are you sure you want to continue connecting (yes\/no)?<\/p><\/blockquote>\n\n\n\n<p>\u9a8c\u8bc1\u60a8\u770b\u5230\u7684\u6d88\u606f\u4e2d\u7684\u6d88\u606f\u4e4b\u4e00\uff0c\u7136\u540e\u8f93\u5165 yes\uff1a\u63d0\u793a\u8fd9\u4e2a\u8868\u793a\u914d\u7f6e\u6210\u529f<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&gt; Hi username! You've successfully authenticated, but GitHub does not<br>&gt; provide shell access.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>1\u5148\u914d\u7f6egiteee\u7684SSH-Key \u751f\u6210\u4e00\u4e2agitee\u7528\u7684SSH-Key\u5bc6\u94a5\uff1a\u8f93\u5165\u547d\u4ee4\uff1a\uff08gitee_id_rsa\u662f\u751f\u6210\u516c\u94a5\u7684\u540d &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[187],"tags":[188,189,191,190],"_links":{"self":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/455"}],"collection":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/comments?post=455"}],"version-history":[{"count":1,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/455\/revisions"}],"predecessor-version":[{"id":456,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/455\/revisions\/456"}],"wp:attachment":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/media?parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/categories?post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/tags?post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}