{"id":19126,"date":"2024-11-19T15:14:06","date_gmt":"2024-11-19T07:14:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19126\/"},"modified":"2024-11-19T15:14:06","modified_gmt":"2024-11-19T07:14:06","slug":"%e8%ae%b2%e8%a7%a3%e5%a6%82%e4%bd%95%e5%9c%a8git%e4%b8%8a%e8%ae%be%e7%bd%aessh-key","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19126\/","title":{"rendered":"\u8bb2\u89e3\u5982\u4f55\u5728Git\u4e0a\u8bbe\u7f6eSSH Key"},"content":{"rendered":"<p>git\u662f\u76ee\u524d\u4e16\u754c\u4e0a\u6700\u6d41\u884c\u7684\u7531linus torvalds\u521b\u7acb\u7684\u7248\u672c\u63a7\u5236\u8f6f\u4ef6\u4e4b\u4e00\u3002\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528git\u5bf9\u4ee3\u7801\u8fdb\u884c\u7248\u672c\u63a7\u5236\u3001\u534f\u4f5c\u5f00\u53d1\u7b49\u3002\u5728\u4f7f\u7528git\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528ssh key\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u4ee5\u4fbf\u4e8e\u6211\u4eec\u7684\u4ee3\u7801\u5e93\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u5b89\u5168\u8fde\u63a5\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u6765\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5728git\u4e0a\u8bbe\u7f6essh key\u3002<\/p>\n<p>\u4e00\u3001\u751f\u6210SSH Key<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u3002<\/li>\n<li>\u8f93\u5165\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ol>\n<pre>ssh-keygen -t rsa -C \"your_email@example.com\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c\u5c06 &#8220;your_email@example.com&#8221; \u66ff\u6362\u4e3a\u4f60\u7684\u90ae\u7bb1\u5730\u5740\u3002<\/p>\n<p>\u6267\u884c\u540e\u4f1a\u51fa\u73b0\u5982\u4e0b\u63d0\u793a\uff1a<\/p>\n<pre>Generating public\/private rsa key pair.\nEnter file in which to save the key (\/Users\/your_user_directory\/.ssh\/id_rsa):<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u76f4\u63a5\u6309\u56de\u8f66\u952e\uff0c\u4f7f\u7528\u9ed8\u8ba4\u60c5\u51b5\u5373\u53ef\u3002\u63a5\u7740\uff0c\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u56de\u8f66\u8df3\u8fc7\u3002<\/p>\n<ol>\n<li>\u751f\u6210\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u5728 .ssh \u76ee\u5f55\u4e0b\u770b\u5230\u4e24\u4e2a\u6587\u4ef6\uff1aid_rsa \u548c id_rsa.pub\u3002<\/li>\n<\/ol>\n<p>\u4e8c\u3001\u5c06SSH Key\u6dfb\u52a0\u5230GitHub\u8d26\u6237<\/p>\n<ol>\n<li>\u767b\u5f55\u4f60\u7684GitHub\u8d26\u6237\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u5934\u50cf\uff0c\u9009\u62e9 <strong>Settings<\/strong>\u3002<\/li>\n<li>\u9009\u62e9 <strong>SSH and GPG keys<\/strong>\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684 <strong>New SSH key<\/strong>\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u6dfb\u52a0SSH Key\u7684\u6846\u4e2d\uff0c\u8f93\u5165Title\u548cKey\u3002<\/li>\n<\/ol>\n<p>Title\u662f\u4e3aSSH Key\u8d77\u7684\u4e00\u4e2a\u540d\u79f0\uff0cKey\u662f\u5728\u7ec8\u7aef\u4e2d\u751f\u6210\u7684SSH Key\u7684\u516c\u94a5\u5185\u5bb9\uff08\u5373 .ssh \u76ee\u5f55\u4e0b\u7684 id_rsa.pub \u6587\u4ef6\u5185\u5bb9\uff09\u3002<\/p>\n<ol>\n<li>\u70b9\u51fb\u6dfb\u52a0\u3002<\/li>\n<\/ol>\n<p>\u4e09\u3001\u5c06SSH Key\u6dfb\u52a0\u5230GitLab\u8d26\u6237<\/p>\n<ol>\n<li>\u767b\u5f55\u4f60\u7684GitLab\u8d26\u6237\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u5934\u50cf\uff0c\u9009\u62e9 <strong>Settings<\/strong>\u3002<\/li>\n<li>\u9009\u62e9 <strong>SSH keys<\/strong>\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684 <strong>Add SSH key<\/strong>\u3002<\/li>\n<\/ol>\n<p>Title\u662f\u4e3aSSH Key\u8d77\u7684\u4e00\u4e2a\u540d\u79f0\uff0cKey\u662f\u5728\u7ec8\u7aef\u4e2d\u751f\u6210\u7684SSH Key\u7684\u516c\u94a5\u5185\u5bb9\uff08\u5373 .ssh \u76ee\u5f55\u4e0b\u7684 id_rsa.pub \u6587\u4ef6\u5185\u5bb9\uff09\u3002<\/p>\n<ol>\n<li>\u70b9\u51fb\u6dfb\u52a0\u3002<\/li>\n<\/ol>\n<p>\u56db\u3001\u5c06SSH Key\u6dfb\u52a0\u5230Bitbucket\u8d26\u6237<\/p>\n<ol>\n<li>\u767b\u5f55\u4f60\u7684Bitbucket\u8d26\u6237\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u5934\u50cf\uff0c\u9009\u62e9 <strong>Bitbucket settings<\/strong>\u3002<\/li>\n<li>\u9009\u62e9 <strong>SSH keys<\/strong>\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684 <strong>Add key<\/strong>\u3002<\/li>\n<\/ol>\n<p>Title\u662f\u4e3aSSH Key\u8d77\u7684\u4e00\u4e2a\u540d\u79f0\uff0cKey\u662f\u5728\u7ec8\u7aef\u4e2d\u751f\u6210\u7684SSH Key\u7684\u516c\u94a5\u5185\u5bb9\uff08\u5373 .ssh \u76ee\u5f55\u4e0b\u7684 id_rsa.pub \u6587\u4ef6\u5185\u5bb9\uff09\u3002<\/p>\n<ol>\n<li>\u70b9\u51fb\u6dfb\u52a0\u3002<\/li>\n<\/ol>\n<p>\u4e94\u3001\u6d4b\u8bd5SSH Key<\/p>\n<p>\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ssh -T git@github.com<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5GitHub\u4e3a\u4f8b\uff0c\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u63d0\u793a\u5219\u8868\u793a\u6210\u529f\uff1a<\/p>\n<pre>Hi username! You've successfully authenticated, but GitHub does not provide shell access.<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u9047\u5230\u8fde\u63a5\u95ee\u9898\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u68c0\u67e5SSH Key\u7684\u914d\u7f6e\u3001\u9632\u706b\u5899\u7b49\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8bb2\u89e3\u5982\u4f55\u5728Git\u4e0a\u8bbe\u7f6eSSH Key\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>git\u662f\u76ee\u524d\u4e16\u754c\u4e0a\u6700\u6d41\u884c\u7684\u7531linus torvalds\u521b\u7acb\u7684\u7248\u672c\u63a7\u5236\u8f6f\u4ef6\u4e4b\u4e00\u3002\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528git\u5bf9\u4ee3\u7801\u8fdb\u884c\u7248\u672c\u63a7\u5236\u3001\u534f\u4f5c\u5f00\u53d1\u7b49\u3002\u5728\u4f7f\u7528git\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528ssh key\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u4ee5\u4fbf\u4e8e\u6211\u4eec\u7684\u4ee3\u7801\u5e93\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u5b89\u5168\u8fde\u63a5\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u6765\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5728git\u4e0a\u8bbe\u7f6essh key\u3002 \u4e00\u3001\u751f\u6210SSH Key \u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u3002 \u8f93\u5165\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a ssh-keygen -t rsa -C &#8220;your_email@example.com&#8221; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u5c06 &#8220;your_email@example.com&#8221; \u66ff\u6362\u4e3a\u4f60\u7684\u90ae\u7bb1\u5730\u5740\u3002 \u6267\u884c\u540e\u4f1a\u51fa\u73b0\u5982\u4e0b\u63d0\u793a\uff1a Generating public\/private rsa key pair. Enter file in which to save the key (\/Users\/your_user_directory\/.ssh\/id_rsa): \u767b\u5f55\u540e\u590d\u5236 \u76f4\u63a5\u6309\u56de\u8f66\u952e\uff0c\u4f7f\u7528\u9ed8\u8ba4\u60c5\u51b5\u5373\u53ef\u3002\u63a5\u7740\uff0c\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u56de\u8f66\u8df3\u8fc7\u3002 \u751f\u6210\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u5728 .ssh \u76ee\u5f55\u4e0b\u770b\u5230\u4e24\u4e2a\u6587\u4ef6\uff1aid_rsa \u548c id_rsa.pub\u3002 \u4e8c\u3001\u5c06SSH Key\u6dfb\u52a0\u5230GitHub\u8d26\u6237 \u767b\u5f55\u4f60\u7684GitHub\u8d26\u6237\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u5934\u50cf\uff0c\u9009\u62e9 Settings\u3002 \u9009\u62e9 SSH and GPG keys\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2\u7684 New SSH key\u3002 \u5728\u5f39\u51fa\u7684\u6dfb\u52a0SSH Key\u7684\u6846\u4e2d\uff0c\u8f93\u5165Title\u548cKey\u3002 [&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-19126","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19126","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=19126"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19126\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}