{"id":1992,"date":"2021-01-20T14:32:40","date_gmt":"2021-01-20T06:32:40","guid":{"rendered":"http:\/\/www.laihp.top\/zqb\/?p=1992"},"modified":"2022-02-22T10:43:58","modified_gmt":"2022-02-22T02:43:58","slug":"ubuntu%e6%a1%8c%e9%9d%a2%e7%89%88%e5%8f%8aserver%e7%89%88%e5%90%af%e7%94%a8root%e7%94%a8%e6%88%b7%e7%99%bb%e5%bd%95%e5%b9%b6%e7%94%a8%e7%a7%98%e9%92%a5%e6%96%b9%e5%bc%8f%e7%99%bb%e5%bd%95","status":"publish","type":"post","link":"https:\/\/www.laihp.top\/zqb\/?p=1992","title":{"rendered":"Ubuntu\u684c\u9762\u7248\u53caserver\u7248\u542f\u7528root\u7528\u6237\u767b\u5f55\u5e76\u7528\u79d8\u94a5\u65b9\u5f0f\u767b\u5f55\u4ee5\u53ca\u66f4\u6362\u79d8\u94a5"},"content":{"rendered":"<h1><strong>\u9ed8\u8ba4\u5b89\u88c5Ubuntu\u90fd\u662f\u4e0d\u5141\u8bb8\u4ee5root\u7528\u6237\u8fdb\u884c\u767b\u5f55\u7684\uff0c\u60f3\u8981\u4ee5root\u7528\u6237\u8fdb\u884c\u767b\u5f55\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u64cd\u4f5c\uff0c\u4e3b\u8981\u662f\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/strong><\/h1>\n<h2>\u4e00\u3001ubuntu 16.04 server\u542f\u7528root\u7528\u6237\u65b9\u6cd5<\/h2>\n<p>\u9996\u5148\uff1a\u4f7f\u7528sudo passwd root\u547d\u4ee4\u8bbe\u7f6eroot\u7684\u5bc6\u7801<\/p>\n<p>\u5176\u6b21\uff1a\u4fee\u6539\/etc\/ssh\/sshd_config\u6587\u4ef6<\/p>\n<p>1\u3001vim \/etc\/ssh\/sshd_config<br \/>\n2\u3001\u628aPermitRootLogin Prohibit-password \u6dfb\u52a0#\u6ce8\u91ca\u6389<br \/>\n3\u3001\u65b0\u6dfb\u52a0\uff1aPermitRootLogin yes<br \/>\n4\u3001\u91cd\u542fssh\u670d\u52a1\/etc\/init.d\/ssh restart<\/p>\n<h2>\u4e8c\u3001ubuntu 16.04 \u684c\u9762\u7248\u542f\u7528root\u7528\u6237\u65b9\u6cd5<\/h2>\n<div>1<\/div>\n<div>.\u9996\u5148\u8bbe\u7f6eroot\u7528\u6237\u5bc6\u7801\uff1a<\/div>\n<div># sudo passwd root<\/div>\n<div>\u8f93\u5165\u666e\u901a\u7528\u6237\u5bc6\u7801,\u518d\u8f93\u5165root\u7528\u6237\u5bc6\u7801\uff1b<\/div>\n<div>2.\u542f\u7528\u767b\u5f55\u65f6\u7684root\u9009\u9879\uff1a<\/div>\n<div>\u7f16\u8f9150-ubuntu.conf\u6587\u4ef6\uff1a<\/div>\n<div># sudo gedit \/usr\/share\/lightdm\/lightdm.conf.d\/50-ubuntu.conf<\/div>\n<div>\u6dfb\u52a0\uff1a<\/div>\n<div>greeter-show-manual-login=true<\/div>\n<div>\u7f16\u8f91\/root\/.profile\u6587\u4ef6\uff1a<\/div>\n<div># sudo gedit \/root\/.profile<\/div>\n<div>\u627e\u5230 mesg n\u8fd9\u4e00\u884c\uff0c\u4fee\u6539\u4e3a\uff1a<\/div>\n<div>tty -s &amp;&amp; mesg n<\/div>\n<div>\u4fdd\u5b58\u9000\u51fa~<\/div>\n<div>3.\u914d\u7f6eroot\u81ea\u52a8\u767b\u9646\uff1a<\/div>\n<div>\u7f16\u8f91lightdm.conf\u6587\u4ef6\uff1a<\/div>\n<div># sudo gedit\u00a0 \/etc\/lightdm\/lightdm.conf<\/div>\n<div>\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\uff1a<\/div>\n<div>[SeatDefaults]<\/div>\n<div>autologin-user=root<\/div>\n<div>greeter-session=unity-greeter<\/div>\n<div>user-session=ubuntu<\/div>\n<div>greeter-show-manual-login=true<\/div>\n<div>allow-guest=false<\/div>\n<div>\u4fdd\u5b58\u91cd\u542f\u5b8c\u4e8b~<\/div>\n<div><\/div>\n<div>\n<hr \/>\n<\/div>\n<h1><span style=\"color: #ff0000;\"><strong>\u79d8\u94a5\u65b9\u5f0f\u767b\u5f55\uff1a<\/strong><\/span><\/h1>\n<h3>\u9996\u5148\u786e\u5b9a\u4f60\u53ef\u4ee5\u4ee5\u5bc6\u7801\u7684\u5f62\u5f0f\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u975e\u8d85\u7ea7\u7ba1\u7406\u5458\u7528\u6237\uff0c\u5e76\u589e\u52a0 sudo \u6743\u9650\u3002<\/h3>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">$ sudo ssh root@12.34.56.78<\/code><\/pre>\n<p>\u751f\u6210 .pem \u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<h3>1.\u5ba2\u6237\u7aef\uff08\u672c\u5730\u4e3b\u673a \uff09\u751f\u6210\u9a8c\u8bc1\u6ca1\u6709\u5bc6\u7801\u5bc6\u94a5\u5bf9<\/h3>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">$ ssh-keygen -t rsa -b 2048 -v<\/code><\/pre>\n<p>\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u9996\u5148\u4f1a\u8ba9\u4f60\u8f93\u5165\u751f\u6210\u5bc6\u94a5\u7684\u6587\u4ef6\u540d\uff1a\u6211\u8fd9\u91cc\u8f93\u5165\u7684 myPemKey \uff0c\u4e4b\u540e\u4e00\u8def\u56de\u8f66\u3002<\/p>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">Generating public\/private rsa key pair.\r\nEnter file in which to save the key (\/home\/anonymouse\/.ssh\/id_rsa): myPemKey\r\nEnter passphrase (empty for no passphrase): \r\nEnter same passphrase again: \r\nYour identification has been saved in hetzner.\r\nYour public key has been saved in hetzner.pub.\r\nThe key fingerprint is:\r\nbb:c6:9c:ee:6b:c0:67:58:b2:bb:4b:44:72:d3:cc:a5 localhost@localhost\r\nThe key's randomart image is:\r\n<\/code><\/pre>\n<p>\u5728\u6267\u884c\u547d\u4ee4\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\u4f1a\u751f\u6210\u4e00\u4e2amyPemKey.pub\u3001myPemKey \u4e24\u4e2a\u6587\u4ef6\u3002<\/p>\n<h3>2. \u628a\u751f\u6210\u7684 myPemKey.pub \u901a\u8fc7\u672c\u5730\u547d\u4ee4\u63a8\u9001\u5230\u670d\u52a1\u5668\u7aef\uff0c\u4f7f\u670d\u52a1\u5668\u81ea\u52a8\u6dfb\u52a0\u8ba4\u8bc1\u8fd9\u4e2a\u8bc1\u4e66<\/h3>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">$ ssh-copy-id -i ~\/myPemKey.pub root@12.34.56.78<\/code><\/pre>\n<p>\u8f93\u5165\u4f60\u7684 root \u7528\u6237\u5bc6\u7801<\/p>\n<h3>3. \u6d4b\u8bd5\u8fde\u63a5<\/h3>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">$ sudo ssh -i ~\/myPemKey root@12.34.56.78<\/code><\/pre>\n<p>\u6216\u8005\u628a myPemKey \u91cd\u547d\u540d\u4e3a myPemKey.pem<\/p>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">$ sudo ssh -i ~\/myPemKey.pem root@12.34.56.78<\/code><\/pre>\n<h3>4. \u7981\u7528\u5bc6\u7801\u8fde\u63a5\uff08\u6ce8\u610f\uff1a\u8981\u4fdd\u8bc1 .pem \u8fde\u63a5\u6210\u529f\u7684\u72b6\u6001\u4e0b\uff0c\u7981\u7528\u5bc6\u7801\u8fde\u63a5\uff09<\/h3>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">sudo vi \/etc\/ssh\/sshd_config<\/code><\/pre>\n<p>\u627e\u5230\u8fd9\u4e00\u884c #PasswordAuthentication yes<\/p>\n<pre class=\"prettyprint\"><code class=\"has-numbering\"># Change to no to disable tunnelled clear text passwords\r\n# PasswordAuthentication yes<\/code><\/pre>\n<p>\u53d6\u6d88\u524d\u8fb9\u7684 # \u6ce8\u91ca\uff0c\u6539\u4e3a<\/p>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">PasswordAuthentication no<\/code><\/pre>\n<p>\u91cd\u542f ssh \u670d\u52a1<\/p>\n<pre class=\"prettyprint\"><code class=\"has-numbering\">sudo service ssh restart<\/code><\/pre>\n<hr \/>\n<h1>\u670d\u52a1\u5668\u7aef\u751f\u6210\u79d8\u94a5\u7ed9\u5ba2\u6237\u7aef\u767b\u5f55\u4f7f\u7528\uff1a<\/h1>\n<pre class=\"pure-highlightjs\"><code class=\"null\">ssh-keygen\r\ncd \/root\/.ssh\/\r\ncat id_rsa.pub &gt;&gt;authorized_keys \r\n\r\nvim \/etc\/ssh\/sshd_config\r\n\r\n\u6dfb\u52a0\uff1a\r\n<span class=\"typ\">RSAAuthentication<\/span><span class=\"pln\"> yes \r\n<\/span><span class=\"typ\">PubkeyAuthentication<\/span><span class=\"pln\"> yes<\/span>\r\n\u53e6\u5916\uff0c\u8bf7\u7559\u610f root \u7528\u6237\u80fd\u5426\u901a\u8fc7 SSH \u767b\u5f55\uff1a \r\nPermitRootLogin yes\r\n\u5f53\u4f60\u5b8c\u6210\u5168\u90e8\u8bbe\u7f6e\uff0c\u5e76\u4ee5\u5bc6\u94a5\u65b9\u5f0f\u767b\u5f55\u6210\u529f\u540e\uff0c\u518d\u7981\u7528\u5bc6\u7801\u767b\u5f55\uff1a \r\nPasswordAuthentication no\r\nservice ssh restart \r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2>\u66f4\u6362\u79d8\u94a5<\/h2>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#\u5220\u9664\u539f\u6765\u79d8\u94a5\r\ncd  \/home\/biadmin\/.ssh\/\r\nvim authorized_keys\r\n#\u5220\u9664\u539f\u6765\u7684\u516c\u94a5\u884c\u5373\u53ef\r\n\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9ed8\u8ba4\u5b89\u88c5Ubuntu\u90fd\u662f\u4e0d\u5141\u8bb8\u4ee5root\u7528\u6237\u8fdb\u884c\u767b\u5f55\u7684\uff0c\u60f3\u8981\u4ee5root\u7528\u6237\u8fdb\u884c\u767b\u5f55\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u64cd\u4f5c\uff0c\u4e3b\u8981\u662f\u4ee5\u4e0b &#8230; <a title=\"Ubuntu\u684c\u9762\u7248\u53caserver\u7248\u542f\u7528root\u7528\u6237\u767b\u5f55\u5e76\u7528\u79d8\u94a5\u65b9\u5f0f\u767b\u5f55\u4ee5\u53ca\u66f4\u6362\u79d8\u94a5\" class=\"read-more\" href=\"https:\/\/www.laihp.top\/zqb\/?p=1992\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbUbuntu\u684c\u9762\u7248\u53caserver\u7248\u542f\u7528root\u7528\u6237\u767b\u5f55\u5e76\u7528\u79d8\u94a5\u65b9\u5f0f\u767b\u5f55\u4ee5\u53ca\u66f4\u6362\u79d8\u94a5\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1992","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/1992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1992"}],"version-history":[{"count":8,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/1992\/revisions"}],"predecessor-version":[{"id":2106,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/1992\/revisions\/2106"}],"wp:attachment":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}