{"id":62,"date":"2021-09-18T22:35:30","date_gmt":"2021-09-18T14:35:30","guid":{"rendered":"https:\/\/benson.ml\/?p=62"},"modified":"2022-03-23T13:45:40","modified_gmt":"2022-03-23T05:45:40","slug":"linux-%e8%b0%b7%e6%ad%8c%e4%ba%91%e5%bc%80%e5%90%afssh%e5%8f%8a%e8%ae%be%e7%bd%aeroot%e5%af%86%e7%a0%81","status":"publish","type":"post","link":"https:\/\/benson80.eu.org\/?p=62","title":{"rendered":"LINUX | \u8c37\u6b4c\u4e91\u5f00\u542fSSH\u53ca\u8bbe\u7f6eroot\u5bc6\u7801"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u8bbe\u7f6eroot\u5bc6\u7801<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.\u5148\u9009\u62e9\u4ece\u6d4f\u89c8\u5668\u6253\u5f00ssh\u8fde\u63a5\u670d\u52a1\u5668<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">2.\u5207\u6362\u5230root\u8d26\u53f7<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -i<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u8bbe\u7f6eroot\u5bc6\u7801<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>passwd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7136\u540e\u4f1a\u8981\u6c42\u8f93\u5165\u65b0\u5bc6\u7801\uff0c\u7136\u540e\u518d\u91cd\u590d\u4e00\u6b21\u5bc6\u7801\uff0c\u8f93\u5165\u5bc6\u7801\u7684\u65f6\u5019\u4e0d\u4f1a\u663e\u793a\u51fa\u6765\uff0c\u6240\u4ee5\u76f4\u63a5\u8f93\u5165\u5bc6\u7801\uff0c\u7136\u540e\u56de\u8f66\uff0c\u518d\u7136\u540e\u91cd\u590d\u8f93\u5165\u5bc6\u7801\u56de\u8f66<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u5f00\u542fSSH\u6743\u9650<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">\u2460\u65b9\u6cd5\u4e00<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.\u4fee\u6539SSH\u914d\u7f6e\u6587\u4ef6\/etc\/ssh\/sshd_config<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2.\u7136\u540e\u518d\u8f93\u201di\u201d\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>i<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u627e\u5230\u4ee5\u4e0b\u5185\u5bb9\u5e76\u4fee\u6539<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>PermitRootLogin yes           \/\/\u9ed8\u8ba4\u4e3ano\uff0c\u9700\u8981\u5f00\u542froot\u7528\u6237\u8bbf\u95ee\u6539\u4e3ayes\nPasswordAuthentication yes    \/\/\u9ed8\u8ba4\u4e3ano\uff0c\u6539\u4e3ayes\u5f00\u542f\u5bc6\u7801\u767b\u9646<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u518d\u4e0b\u6309 esc \u952e\uff0c\u7136\u540e\u518d\u8f93\u5165<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>:wq<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5.\u91cd\u542fSSH\u670d\u52a1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>service sshd restart<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461\u65b9\u6cd5\u4e8c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">CentOS\u548cDebian\u901a\u7528\uff0c\u8f93\u5165\u4ee5\u4e0b\u4e24\u6761\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/PermitRootLogin no\/PermitRootLogin yes\/g' \/etc\/ssh\/sshd_config\nsed -i 's\/PasswordAuthentication no\/PasswordAuthentication yes\/g' \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Ubuntu\u7cfb\u7edf\uff0c\u8f93\u5165\u4ee5\u4e0b\u4e24\u6761\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/#PermitRootLogin prohibit-password\/PermitRootLogin yes\/g' \/etc\/ssh\/sshd_config\nsed -i 's\/PasswordAuthentication no\/PasswordAuthentication yes\/g' \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u542f\u670d\u52a1\u5668<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>reboot<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u8bbe\u7f6eroot\u5bc6\u7801 1.\u5148\u9009\u62e9\u4ece\u6d4f\u89c8\u5668\u6253\u5f00ssh &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":1,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}