{"id":315,"date":"2022-11-23T14:27:48","date_gmt":"2022-11-23T06:27:48","guid":{"rendered":"https:\/\/www.guger.top\/?p=315"},"modified":"2022-11-23T14:27:57","modified_gmt":"2022-11-23T06:27:57","slug":"ssh%e5%af%86%e9%92%a5%e8%bf%9c%e7%a8%8b%e7%99%bb%e5%bd%95%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.guger.top\/index.php\/2022\/11\/23\/ssh%e5%af%86%e9%92%a5%e8%bf%9c%e7%a8%8b%e7%99%bb%e5%bd%95%e6%9c%8d%e5%8a%a1%e5%99%a8\/","title":{"rendered":"ssh\u5bc6\u94a5\u8fdc\u7a0b\u767b\u5f55\u670d\u52a1\u5668"},"content":{"rendered":"<h1>\u9996\u5148\u5bc6\u94a5\u767b\u5f55\u662f\u89e3\u51b3\u5b89\u5168\u6027\u7684\u95ee\u9898<\/h1>\n<p>\u4e00\u822c\u7684\u5bc6\u7801\u65b9\u5f0f\u767b\u5f55\uff0c\u5bb9\u6613\u6709\u5bc6\u7801\u88ab\u66b4\u529b\u7834\u89e3\u7684\u95ee\u9898\u3002\u6240\u4ee5\uff0c\u4e00\u822c\u6211\u4eec\u4f1a\u5c06 SSH \u7684\u7aef\u53e3\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7684 22 \u4ee5\u5916\u7684\u7aef\u53e3\uff0c\u6216\u8005\u7981\u7528 root \u8d26\u6237\u767b\u5f55\u3002\u5176\u5b9e\uff0c\u6709\u4e00\u4e2a\u66f4\u597d\u7684\u529e\u6cd5\u6765\u4fdd\u8bc1\u5b89\u5168\uff0c\u800c\u4e14\u8ba9\u4f60\u53ef\u4ee5\u653e\u5fc3\u5730\u7528 root \u8d26\u6237\u4ece\u8fdc\u7a0b\u767b\u5f55\u2014\u2014\u90a3\u5c31\u662f\u901a\u8fc7\u5bc6\u94a5\u65b9\u5f0f\u767b\u5f55\u3002\u76f4\u63a5\u539f\u56e0\uff0cvscode\u4f7f\u7528\u5bc6\u94a5\u767b\u5f55\u66f4\u65b9\u4fbf<\/p>\n<h1>\u5236\u4f5c\u5bc6\u94a5<\/h1>\n<pre><code class=\"language-shell\">[root@host ~]$ ssh-keygen  &lt;== \u5efa\u7acb\u5bc6\u94a5\u5bf9\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/root\/.ssh\/id_rsa): &lt;== \u6309 Enter\nCreated directory &#039;\/root\/.ssh&#039;.\nEnter passphrase (empty for no passphrase): &lt;== \u8f93\u5165\u5bc6\u94a5\u9501\u7801\uff0c\u6216\u76f4\u63a5\u6309 Enter \u7559\u7a7a\nEnter same passphrase again: &lt;== \u518d\u8f93\u5165\u4e00\u904d\u5bc6\u94a5\u9501\u7801\nYour identification has been saved in \/root\/.ssh\/id_rsa. &lt;== \u79c1\u94a5\nYour public key has been saved in \/root\/.ssh\/id_rsa.pub. &lt;== \u516c\u94a5\nThe key fingerprint is:\n0f:d3:e7:1a:1c:bd:5c:03:f1:19:f1:22:df:9b:cc:08 root@host<\/code><\/pre>\n<h1>\u4f7f\u7528\u5bc6\u94a5<\/h1>\n<p>\u4e00\u822c\u4f7f\u7528\u73af\u5883\u662fwindows\u73af\u5883\u3002\u901a\u8fc7\u4e0a\u8ff0\u8fc7\u7a0b\u751f\u6210\u4e86\u4e24\u4e2a\u6587\u4ef6\u4e00\u4e2a\u662fid_rsa\u548cid_rsa.pub\u3002\u5bc6\u94a5\u662f\u5206\u4e3a\u516c\u94a5\u548c\u79c1\u94a5\u7684\u3002\u516c\u94a5\u662f\u53ef\u4ee5\u5728\u7f51\u7edc\u4e0a\u4f20\u64ad\u7684\uff0c\u79c1\u94a5\u662f\u79d8\u5bc6\u7684\u7981\u6b62\u6cc4\u9732\u7684\u3002\u56e0\u800c\u4e00\u822c\u7ed9\u8bbe\u5907\u5206\u53d1\u516c\u94a5\u3002windows\u4e0a\u7559\u79c1\u94a5\uff0c\u670d\u52a1\u5668\u4e0a\u7559\u516c\u94a5\u3002\u5c06\u79c1\u94a5\u653e\u7f6e\u5728 c:\/user\/\u7528\u6237\u540d\/.ssh\u6587\u4ef6\u5939\u4e0b\u3002\u5c06\u516c\u94a5\u653e\u7f6e\u5728\u670d\u52a1\u5668\u7684 ~\/.ssh\u4e0b\u3002<\/p>\n<pre><code class=\"language-shell\">[root@host ~]$ cd .ssh\n[root@host .ssh]$ cat id_rsa.pub &gt;&gt; authorized_keys\n[root@host .ssh]$ chmod 600 authorized_keys\n[root@host .ssh]$ chmod 700 ~\/.ssh\n[root@host .ssh]$ sudo service sshd restart<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u5bc6\u94a5\u767b\u5f55\u662f\u89e3\u51b3\u5b89\u5168\u6027\u7684\u95ee\u9898 \u4e00\u822c\u7684\u5bc6\u7801\u65b9\u5f0f\u767b\u5f55\uff0c\u5bb9\u6613\u6709\u5bc6\u7801\u88ab\u66b4\u529b\u7834\u89e3\u7684\u95ee\u9898\u3002\u6240\u4ee5\uff0c\u4e00\u822c\u6211\u4eec\u4f1a\u5c06 SSH \u7684\u7aef\u53e3\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7684 2 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":""},"categories":[32,13],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-linux","category-vps"],"_links":{"self":[{"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":0,"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guger.top\/index.php\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}