{"id":21552,"date":"2024-11-19T12:57:32","date_gmt":"2024-11-19T04:57:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21552\/"},"modified":"2024-11-19T12:57:32","modified_gmt":"2024-11-19T04:57:32","slug":"git%e6%80%8e%e4%b9%88%e6%a3%80%e6%b5%8bssh","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21552\/","title":{"rendered":"git\u600e\u4e48\u68c0\u6d4bssh"},"content":{"rendered":"<blockquote><p>\n  \u8981\u901a\u8fc7 git \u68c0\u6d4b ssh\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u751f\u6210 ssh \u5bc6\u94a5\u5bf9\u3002\u5c06\u516c\u94a5\u6dfb\u52a0\u5230 git \u670d\u52a1\u5668\u3002\u914d\u7f6e git \u4f7f\u7528 ssh\u3002\u6d4b\u8bd5 ssh \u8fde\u63a5\u3002\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u89e3\u51b3\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053023515929821.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u68c0\u6d4bssh\u63d2\u56fe\" alt=\"git\u600e\u4e48\u68c0\u6d4bssh\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Git \u68c0\u6d4b SSH<\/strong><\/p>\n<p>\u5728 Git \u4e2d\u4f7f\u7528 SSH \u534f\u8bae\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u751f\u6210 SSH \u5bc6\u94a5\u5bf9<\/strong><\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u4e00\u5bf9\u516c\u94a5\u548c\u79c1\u94a5\uff1a<\/p>\n<pre>ssh-keygen -t rsa -b 4096<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u547d\u4ee4\u7ed3\u675f\u540e\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u94a5\u6587\u4ef6\u7684\u4fdd\u5b58\u8def\u5f84\u548c\u5bc6\u7801\uff08\u5982\u679c\u9700\u8981\uff09\u3002<\/p>\n<p><strong>2. \u6dfb\u52a0\u516c\u94a5\u5230 Git \u670d\u52a1\u5668<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u751f\u6210\u7684\u516c\u94a5\u6dfb\u52a0\u5230 Git \u670d\u52a1\u5668\uff1a<\/p>\n<pre>ssh-copy-id -i ~\/.ssh\/id_rsa.pub git@&lt;\u670d\u52a1\u5668\u5730\u5740&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u66ff\u6362 \u4e3a Git \u670d\u52a1\u5668\u7684\u5730\u5740\u3002<\/p>\n<p><strong>3. \u914d\u7f6e Git \u4f7f\u7528 SSH<\/strong><\/p>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\uff0c\u6253\u5f00 .config \u6587\u4ef6\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre>[remote \"origin\"]\n    url = git@&lt;\u670d\u52a1\u5668\u5730\u5740&gt;:&lt;\u4ed3\u5e93\u540d&gt;.git<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u66ff\u6362 \u548c \u4e3a Git \u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u4ed3\u5e93\u540d\u79f0\u3002<\/p>\n<p><strong>4. \u6d4b\u8bd5 SSH \u8fde\u63a5<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6d4b\u8bd5 SSH \u8fde\u63a5\uff1a<\/p>\n<pre>git clone git@&lt;\u670d\u52a1\u5668\u5730\u5740&gt;:&lt;\u4ed3\u5e93\u540d&gt;.git<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u547d\u4ee4\u6210\u529f\u6267\u884c\uff0c\u5219\u8868\u793a SSH \u8fde\u63a5\u5df2\u6210\u529f\u5efa\u7acb\u3002<\/p>\n<p><strong>5. \u89e3\u51b3\u95ee\u9898<\/strong><\/p>\n<p>\u5982\u679c\u9047\u5230\u68c0\u6d4b SSH \u65f6\u51fa\u73b0\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd Git \u670d\u52a1\u5668\u542f\u7528\u4e86 SSH \u8bbf\u95ee\u3002<\/li>\n<li>\u68c0\u67e5 SSH \u5bc6\u94a5\u5bf9\u662f\u5426\u6709\u6548\u3002<\/li>\n<li>\u68c0\u67e5 .gitconfig \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528 ssh \u547d\u4ee4\u76f4\u63a5\u8fde\u63a5\u5230 Git \u670d\u52a1\u5668\uff0c\u67e5\u770b\u662f\u5426\u6709\u4efb\u4f55\u9519\u8bef\u6d88\u606f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u68c0\u6d4bssh\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u901a\u8fc7 git \u68c0\u6d4b ssh\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u751f\u6210 ssh \u5bc6\u94a5\u5bf9\u3002\u5c06\u516c\u94a5\u6dfb\u52a0\u5230 git \u670d\u52a1\u5668\u3002\u914d\u7f6e git \u4f7f\u7528 ssh\u3002\u6d4b\u8bd5 ssh \u8fde\u63a5\u3002\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u89e3\u51b3\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002 \u5982\u4f55\u4f7f\u7528 Git \u68c0\u6d4b SSH \u5728 Git \u4e2d\u4f7f\u7528 SSH \u534f\u8bae\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u751f\u6210 SSH \u5bc6\u94a5\u5bf9 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u4e00\u5bf9\u516c\u94a5\u548c\u79c1\u94a5\uff1a ssh-keygen -t rsa -b 4096 \u767b\u5f55\u540e\u590d\u5236 \u547d\u4ee4\u7ed3\u675f\u540e\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u94a5\u6587\u4ef6\u7684\u4fdd\u5b58\u8def\u5f84\u548c\u5bc6\u7801\uff08\u5982\u679c\u9700\u8981\uff09\u3002 2. \u6dfb\u52a0\u516c\u94a5\u5230 Git \u670d\u52a1\u5668 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u751f\u6210\u7684\u516c\u94a5\u6dfb\u52a0\u5230 Git \u670d\u52a1\u5668\uff1a ssh-copy-id -i ~\/.ssh\/id_rsa.pub git@&lt;\u670d\u52a1\u5668\u5730\u5740&gt; \u767b\u5f55\u540e\u590d\u5236 \u66ff\u6362 \u4e3a Git \u670d\u52a1\u5668\u7684\u5730\u5740\u3002 3. \u914d\u7f6e Git \u4f7f\u7528 SSH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21552","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21552"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21552\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}