{"id":91,"date":"2018-06-21T11:14:14","date_gmt":"2018-06-21T03:14:14","guid":{"rendered":"http:\/\/47.93.8.114\/wordpress\/?p=91"},"modified":"2018-06-23T19:14:00","modified_gmt":"2018-06-23T11:14:00","slug":"gitwithopenssh","status":"publish","type":"post","link":"http:\/\/www.threebrush.com\/wordpress\/index.php\/2018\/06\/21\/gitwithopenssh\/","title":{"rendered":"git\u4f7f\u7528openssh\u65b9\u5f0f\u8bbf\u95ee"},"content":{"rendered":"<p>git\u670d\u52a1\u5668\u642d\u5efa\u597d\u4ee5\u540e\uff0cgit\u5ba2\u6237\u7aef\u6709\u4e24\u79cd\u65b9\u5f0f\u8bbf\u95ee\u670d\u52a1\u5668\uff0c\u4e00\u79cd\u662fhttps\u65b9\u5f0f\uff0c\u4e00\u79cd\u662fssh\u65b9\u5f0f\uff0c\u4f7f\u7528ssh\u65b9\u5f0f\u53ef\u4ee5\u907f\u514d\u6bcf\u6b21\u63d0\u4ea4\u90fd\u8981\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801<\/p>\n<p>\u5728sourcetree\u5f53\u4e2d\u7528openssh\u65b9\u5f0f\u8bbf\u95ee\u81ea\u5df1\u642d\u5efa\u7684\u670d\u52a1\u5668\uff0cclone\u65f6\u76f4\u63a5\u8f93\u5165git@ip\u5730\u5740:\/data\/git\/threebrush.git<\/p>\n<p>\u4f1a\u63d0\u793a\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684git\u5730\u5740\uff0c\u8be6\u7ec6\u4fe1\u606fPermission denied (publickey,gssapi-keyex,gssapi-with-mic)\uff0c<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b<\/p>\n<p>1.\u9996\u5148\u5728\u5ba2\u6237\u7aef\u672c\u673a\u521b\u5efa\u79c1\u94a5\uff0c\u53ef\u4ee5\u5728bash\u91cc\u7528\u547d\u4ee4\u521b\u5efa<\/p>\n<p><span class=\"hljs-comment\"># \u521b\u5efa\u79c1\u94a5\uff0c\u6587\u4ef6\u4f4d\u4e8e\u7528\u6237\u4e3b\u76ee\u5f55\u91cc\u627e\u5230.ssh\u76ee\u5f55\uff0c\u91cc\u9762\u6709id_rsa\u548cid_rsa.pub\u4e24\u4e2a\u6587\u4ef6<\/span><\/p>\n<p><span class=\"hljs-variable\">$ <\/span>ssh-keygen -t rsa &#8211;<span class=\"hljs-constant\">C<\/span> <span class=\"hljs-string\">&#8220;youremail@example.com&#8221;<\/span><\/p>\n<p>2.\u670d\u52a1\u5668git\u76ee\u5f55\u4e0b\u521b\u5efa.ssh\u76ee\u5f55\u548cauthorized_keys\u6743\u9650\u6587\u4ef6<\/p>\n<pre class=\"prettyprint prettyprinted\"><span class=\"pln\">$ cd <span class=\"pun\">\/home\/git\/\r\n$ mkdir .ssh #\u65b0\u5efa\u6587\u4ef6\u5939\r\n$ chmod <span class=\"lit\">700 .ssh \r\n$ touch .ssh\/authorized_keys  #\u65b0\u5efa\u6587\u4ef6\r\n$ chmod 600 .ssh\/authorized_keys<\/span><\/span><\/span><\/pre>\n<p>3.\u62f7\u8d1d\u5ba2\u6237\u5355\u751f\u6210\u7684id_rsa.pub\u6587\u4ef6\u5230\u8fd9\u4e2a\u6743\u9650\u6587\u4ef6\u91cc<\/p>\n<p>#\u00a0cat \/tmp\/id_rsa.pub &gt;&gt; \/home\/git\/.ssh\/authorized_keys #\u5c06\u4e0a\u4f20\u7684id_rsa.pub\u7684\u516c\u94a5\u5199\u5165\u5230\u6743\u9650\u6587\u4ef6<\/p>\n<p>\u518d\u6b21clone\u6210\u529f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git\u670d\u52a1\u5668\u642d\u5efa\u597d\u4ee5\u540e\uff0cgit\u5ba2\u6237\u7aef\u6709\u4e24\u79cd\u65b9\u5f0f\u8bbf\u95ee\u670d\u52a1\u5668\uff0c\u4e00\u79cd\u662fhttps\u65b9\u5f0f\uff0c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/91"}],"collection":[{"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":1,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":92,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/91\/revisions\/92"}],"wp:attachment":[{"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.threebrush.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}