{"id":37409,"date":"2025-05-15T22:36:10","date_gmt":"2025-05-15T14:36:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/37409.html"},"modified":"2025-05-15T22:36:10","modified_gmt":"2025-05-15T14:36:10","slug":"%e3%80%90ssh%e5%85%8d%e5%af%86%e3%80%91linux%e4%bd%bf%e7%94%a8publickey%e5%85%ac%e9%92%a5%e5%85%8d%e5%af%86%e7%99%bb%e5%bd%95%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/37409.html","title":{"rendered":"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u5728SSH&#xff08;Secure Shell&#xff09;\u4e2d&#xff0c;\u516c\u94a5&#xff08;Public Key&#xff09;\u548c\u79c1\u94a5&#xff08;Private Key&#xff09;\u662f\u4e00\u5bf9\u5bc6\u94a5&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u5b89\u5168\u7684\u8eab\u4efd\u9a8c\u8bc1\u548c\u52a0\u5bc6\u901a\u4fe1<\/p>\n<ul>\n<li>\u516c\u94a5&#xff08;Public Key&#xff09;&#xff1a;\u53ef\u4ee5\u516c\u5f00\u5206\u53d1&#xff0c;\u901a\u5e38\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u6216\u5176\u4ed6\u5ba2\u6237\u7aef&#xff0c;\u670d\u52a1\u5668\u4f1a\u5c06\u516c\u94a5\u5b58\u50a8\u5728\u7528\u6237\u7684\u6388\u6743\u6587\u4ef6&#xff08;\u5982~\/.ssh\/authorized_keys&#xff09;\u4e2d<\/li>\n<li>\u79c1\u94a5&#xff08;Private Key&#xff09;&#xff1a;\u5fc5\u987b\u4e25\u683c\u4fdd\u5bc6&#xff0c;\u4e0d\u80fd\u6cc4\u9732\u3002\u79c1\u94a5\u7528\u4e8e\u5728\u5ba2\u6237\u7aef\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u53ea\u6709\u6301\u6709\u6b63\u786e\u79c1\u94a5\u7684\u7528\u6237\u624d\u80fd\u901a\u8fc7SSH\u8fde\u63a5\u5230\u670d\u52a1\u5668<\/li>\n<\/ul>\n<h2>1.\u751f\u6210\u672c\u5730\u5bc6\u94a5<\/h2>\n<p>\u6253\u5f00\u7ec8\u7aef&#xff0c;\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<p>ssh-keygen <span class=\"token parameter variable\">-t<\/span> rsa <span class=\"token parameter variable\">-b<\/span> <span class=\"token number\">4096<\/span> <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">&#034;your_email&#064;example.com&#034;<\/span><\/p>\n<p>-t rsa&#xff1a;\u6307\u5b9a\u5bc6\u94a5\u7c7b\u578b\u4e3aRSA\u3002<br \/>\n-b 4096&#xff1a;\u6307\u5b9a\u5bc6\u94a5\u957f\u5ea6\u4e3a4096\u4f4d&#xff0c;\u66f4\u9ad8\u7684\u4f4d\u6570\u610f\u5473\u7740\u66f4\u5f3a\u7684\u5b89\u5168\u6027\u3002<br \/>\n-C &#034;your_email&#064;example.com&#034;&#xff1a;\u6dfb\u52a0\u6ce8\u91ca&#xff0c;\u901a\u5e38\u662f\u7528\u6237\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740&#xff0c;\u6709\u52a9\u4e8e\u8bc6\u522b\u5bc6\u94a5<\/p>\n<p>\u7cfb\u7edf\u4f1a\u63d0\u793a\u8f93\u5165\u6587\u4ef6\u540d\u4ee5\u4fdd\u5b58\u5bc6\u94a5&#xff0c;\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u4e3a~\/.ssh\/id_rsa\u3002\u8fd8\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u8bbe\u7f6e\u5bc6\u7801\u77ed\u8bed&#xff08;passphrase&#xff09;&#xff0c;\u8bbe\u7f6e\u5bc6\u7801\u77ed\u8bed\u53ef\u4ee5\u589e\u52a0\u989d\u5916\u7684\u5b89\u5168\u5c42\u3002 \u751f\u6210\u7684\u5bc6\u94a5\u5bf9\u5305\u62ec&#xff1a;<\/p>\n<p>id_rsa&#xff1a;\u79c1\u94a5\u6587\u4ef6\u3002<br \/>\nid_rsa.pub&#xff1a;\u516c\u94a5\u6587\u4ef6<\/p>\n<h2>2.\u4e0a\u4f20\u5bc6\u94a5\u5230\u670d\u52a1\u5668<\/h2>\n<h5>2.1.\u4f7f\u7528ssh-copy-id\u4e0a\u4f20<\/h5>\n<p>ssh-copy-id \u662f\u4e00\u4e2a\u975e\u5e38\u5b9e\u7528\u7684\u547d\u4ee4\u884c\u5de5\u5177&#xff0c;\u7528\u4e8e\u5c06\u672c\u5730\u7528\u6237\u7684\u516c\u94a5\u590d\u5236\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u7684 ~\/.ssh\/authorized_keys \u6587\u4ef6\u4e2d&#xff0c;\u4ece\u800c\u5b9e\u73b0\u514d\u5bc6\u767b\u5f55\u3002\u5b83\u7b80\u5316\u4e86\u624b\u52a8\u5c06\u516c\u94a5\u6dfb\u52a0\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u8fc7\u7a0b&#xff0c;\u7ec8\u7aef\u64cd\u4f5c\u5982\u4e0b&#xff1a;<\/p>\n<p>ssh-copy-id <span class=\"token parameter variable\">-i<\/span> id_rsa.pub user_name&#064;ip_address<\/p>\n<h5>2.2.\u624b\u52a8\u4fee\u6539\u670d\u52a1\u5668.\/ssh\/authorized_keys&#xff0c;\u6dfb\u52a0public_key<\/h5>\n<p>\u5b8c\u6210\u64cd\u4f5c\u540e\u63d0\u793a&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515143609-6825fbd9857a1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/>\u6b64\u65f6\u5728\u670d\u52a1\u5668\u7684.\/ssh\/authorized_keys\u6587\u4ef6\u4e2d\u8bb0\u5f55\u4e86\u516c\u94a5 \u540e\u7eedssh\u5c31\u514d\u5bc6\u4e86<\/p>\n<h2>3.\u4ec5\u53ef\u4f7f\u7528public key\u767b\u5f55\u670d\u52a1\u5668(\u4e0d\u53ef\u7528\u5bc6\u7801)<\/h2>\n<p>\u5728 \/etc\/ssh\/sshd_config\u4e2d\u914d\u7f6e\u4e00\u4e0b\u5b57\u6bb5<\/p>\n<p>PubkeyAuthentication <span class=\"token function\">yes<\/span><br \/>\nPasswordAuthentication no<\/p>\n<p>\u91cd\u542fssh\u670d\u52a1<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl restart sshd<\/p>\n<p>\u5b8c\u6210\u540e&#xff0c;\u5ba2\u6237\u7aef\u53ea\u80fd\u901a\u8fc7\u6dfb\u52a0\u8fc7public_key\u6765\u8bbf\u95ee\u670d\u52a1\u5668&#xff0c;\u8be5\u65b9\u6cd5\u53ef\u4ee5\u5f88\u597d\u7684\u9650\u5236\u767b\u5f55\u7528\u6237<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb541\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728SSH\uff08Secure Shell\uff09\u4e2d\uff0c\u516c\u94a5\uff08Public Key\uff09\u548c\u79c1\u94a5\uff08Private Key\uff09\u662f\u4e00\u5bf9\u5bc6\u94a5\uff0c\u7528\u4e8e\u5b9e\u73b0\u5b89\u5168\u7684\u8eab\u4efd\u9a8c\u8bc1\u548c\u52a0\u5bc6\u901a\u4fe1\u3002_linux\u516c\u94a5\u514d\u5bc6\u767b\u5f55<\/p>\n","protected":false},"author":2,"featured_media":37408,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,77,43],"topic":[],"class_list":["post-37409","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-ssh","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/37409.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb541\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728SSH\uff08Secure Shell\uff09\u4e2d\uff0c\u516c\u94a5\uff08Public Key\uff09\u548c\u79c1\u94a5\uff08Private Key\uff09\u662f\u4e00\u5bf9\u5bc6\u94a5\uff0c\u7528\u4e8e\u5b9e\u73b0\u5b89\u5168\u7684\u8eab\u4efd\u9a8c\u8bc1\u548c\u52a0\u5bc6\u901a\u4fe1\u3002_linux\u516c\u94a5\u514d\u5bc6\u767b\u5f55\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/37409.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-15T14:36:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515143609-6825fbd9857a1.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37409.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/37409.html\",\"name\":\"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-15T14:36:10+00:00\",\"dateModified\":\"2025-05-15T14:36:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/37409.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/37409.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37409.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/37409.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb541\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728SSH\uff08Secure Shell\uff09\u4e2d\uff0c\u516c\u94a5\uff08Public Key\uff09\u548c\u79c1\u94a5\uff08Private Key\uff09\u662f\u4e00\u5bf9\u5bc6\u94a5\uff0c\u7528\u4e8e\u5b9e\u73b0\u5b89\u5168\u7684\u8eab\u4efd\u9a8c\u8bc1\u548c\u52a0\u5bc6\u901a\u4fe1\u3002_linux\u516c\u94a5\u514d\u5bc6\u767b\u5f55","og_url":"https:\/\/www.wsisp.com\/helps\/37409.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-15T14:36:10+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515143609-6825fbd9857a1.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/37409.html","url":"https:\/\/www.wsisp.com\/helps\/37409.html","name":"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-15T14:36:10+00:00","dateModified":"2025-05-15T14:36:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/37409.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/37409.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/37409.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010SSH\u514d\u5bc6\u3011Linux\u4f7f\u7528PublicKey\u516c\u94a5\u514d\u5bc6\u767b\u5f55\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=37409"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37409\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/37408"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=37409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=37409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=37409"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=37409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}