{"id":507,"date":"2019-07-09T23:12:00","date_gmt":"2019-07-09T15:12:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=507"},"modified":"2023-11-03T23:14:14","modified_gmt":"2023-11-03T15:14:14","slug":"git-public-key","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/507","title":{"rendered":"Git public key"},"content":{"rendered":"\n<p><strong>\u532f\u5165public key\u5230online git server<\/strong><br>\u6709\u4e9b\u5c08\u6848\u9700\u8981\u4e8b\u5148\u63d0\u4f9bpublic key\u5230\u5e73\u53f0\u4e0a\uff0c\u624d\u53ef\u4ee5\u4f7f\u7528\u5c08\u6848<\/p>\n\n\n\n<p><strong>\u65b9\u6cd5\u4e3b\u8981\u5206\u5169\u500b\u6b65\u9a5f\uff1a<\/strong><br>\u6b65\u9a5f1.add your key to git platform<br>\u6b65\u9a5f2.Check your SSH access<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9a5f1.add your key to git platform<\/h2>\n\n\n\n<p><strong>1.check whether exist ssh key<\/strong><br><strong># ls -al ~\/.ssh<\/strong><br>\u5982\u679c\u6c92\u6709key\u5c31\u900f\u904e\u6b65\u9a5f2\u7522\u751fkey<br>\u5982\u679c\u6709key\u5c31\u76f4\u63a5\u5230\u6b65\u9a5f3\u8f38\u51fakey<br><strong>2.Generating a new SSH key<\/strong><br><strong># ssh-keygen -t rsa -b 4096 -C &#8220;raymond0820@gmail.com&#8221;<\/strong><br>Generating public\/private rsa key pair.<br>Enter file in which to save the key (\/root\/.ssh\/id_rsa):<br>Enter passphrase (empty for no passphrase):&nbsp;<strong>&lt; \u9023\u5230git server\u6703\u7528\u5230\u81ea\u8a02\u5bc6\u78bc&gt;<\/strong><br>Enter same passphrase again:<br>Your identification has been saved in \/root\/.ssh\/id_rsa.<br>Your public key has been saved in \/root\/.ssh\/id_rsa.pub.<br>The key fingerprint is:<br>8a:90:57:10:6f:57:4f:0e:ef:cb:fb:2a:95:4a:f5:01 raymond0820@gmail.com<br>The key&#8217;s randomart image is:<br>+&#8211;[ RSA 4096]&#8212;-+<br>| o. o . |<br>| o . *E |<br>| + . +. |<br>| . o . .. . |<br>| o . S ..o . |<br>| o . . ..o.. |<br>| . . . oo |<br>| o . |<br>| .oo. |<br>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br>3.output you key and paste to github or gitlab<br><strong># cat ~\/.ssh\/id_rsa.pub<\/strong><br>4.(optional) Adding key to the ssh-agent<br><strong># ssh-add ~\/.ssh\/id_rsa<\/strong><\/p>\n\n\n\n<p>refer<br>Adding a new SSH key to your GitHub account.<br>https:\/\/help.github.com\/articles\/generating-an-ssh-key\/<\/p>\n\n\n\n<p><br>&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9a5f2.Check your SSH access<\/h2>\n\n\n\n<p>\u78ba\u4fddlocal\u548conline git server\u4e4b\u9593\u7684\u5e95\u5c64\u50b3\u8f38\u662f\u5426\u6b63\u78ba<\/p>\n\n\n\n<p><strong>#ssh -T git@github.com<\/strong><br>Warning: Permanently added the RSA host key for IP address &#8216;192.30.253.113&#8217; to the list of known hosts.<br>Enter passphrase for key &#8216;\/root\/.ssh\/id_rsa&#8217;:&nbsp;<strong>&lt; \u9019\u908a\u8981\u8f38\u5165\u505akey\u6642\u7528\u7684passphrase&gt;<\/strong><br>Hi Raymond0820! You&#8217;ve successfully authenticated, but GitHub does not provide shell access.<\/p>\n\n\n\n<p>or<\/p>\n\n\n\n<p><strong>#ssh -T -ai ~\/.ssh\/id_rsa_raymond0820 git@github.com<\/strong><br>Enter passphrase for key &#8216;\/root\/.ssh\/id_rsa_raymond0820&#8217;:<br>Hi Raymond0820! You&#8217;ve successfully authenticated, but GitHub does not provide shell access.<\/p>\n\n\n\n<p>ps:<br>\u82e5\u4e8b\u524d\u6c92\u6709\u5148\u63d0\u4f9bpublic key\u5230git-hub\uff0c\u5247\u6703\u51fa\u73fePermission denied (publickey).<br><strong>#ssh -T -ai ~\/.ssh\/id_rsa_raymondtestproject git@github.com<\/strong><br>Enter passphrase for key &#8216;\/root\/.ssh\/id_rsa_raymondtestproject&#8217;:<br>Permission denied (publickey).<br>&nbsp;<\/p>\n\n\n\n<p>ps:<br>\u82e5\u51fa\u73fessh: connect to host github.com port 22: Connection refused<br>\u7de8\u8f2f.ssh\/config<br>Host github.com<br>User &lt; email &gt;<br>Hostname ssh.github.com<br>PreferredAuthentications publickey<br>IdentityFile ~\/.ssh\/id_rsa<br>Port 443<br>\u5728\u57f7\u884cssh -T git@github.com\u505a\u6e2c\u8a66<\/p>\n\n\n\n<p><br>refer<br>http:\/\/blog.csdn.net\/fulinus\/article\/details\/38542439<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u532f\u5165public key\u5230online git server &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[14],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-develop"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}