{"id":229,"date":"2011-11-02T21:59:03","date_gmt":"2011-11-02T13:59:03","guid":{"rendered":"http:\/\/www.kiccleaf.com\/?p=229"},"modified":"2011-11-07T22:10:36","modified_gmt":"2011-11-07T14:10:36","slug":"%e6%95%b4%e7%90%86%e4%ba%86%e4%b8%80%e4%bb%bdvps-%e5%ae%89%e5%85%a8%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.kiccleaf.com\/?p=229","title":{"rendered":"\u6574\u7406\u4e86\u4e00\u4efdVPS \u5b89\u5168\u8bbe\u7f6e"},"content":{"rendered":"<p><strong>\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3<\/strong><\/p>\n<p>\u4e0d\u8981\u4f7f\u7528\u9ed8\u8ba4\u7684 22 \u7aef\u53e3\uff0c\u8fd9\u6837\u5f88\u5bb9\u6613\u66b4\u9732 SSH \u670d\u52a1\uff0c\u4e5f\u4e3a\u66b4\u529b\u731c\u89e3\u7528\u6237\u540d\u548c\u5bc6\u7801\u7559\u4e0b\u4e86\u9690\u60a3\u3002\u89e3\u51b3\u65b9\u6cd5\uff1a\u5c06 \/etc\/ssh\/sshd_config \u4e2d\u7684 Port \u6539\u4e3a\u5176\u4ed6\u7aef\u53e3\u3002<\/p>\n<p><strong>\u7981\u6b62 root \u5e10\u53f7 SSH \u767b\u5f55<\/strong><\/p>\n<p>\u8fd9\u6837\u4e5f\u662f\u76f8\u5f53\u5371\u9669\u7684\uff0c\u4e00\u822c\u7684\u505a\u6cd5\u662f\u901a\u8fc7 SSH \u914d\u7f6e\u6587\u4ef6\uff0c\u9650\u5236 root \u5e10\u53f7\u76f4\u63a5\u767b\u5f55\u3002<br \/>\n\u4fee\u6539 \/etc\/ssh\/sshd_config<br \/>\n\u5c06 PermitRootLogin \u7684\u503c\u6539\u4e3a no<br \/>\n\u8fd9\u6837\uff0cSSH \u4e00\u5f8b\u4f7f\u7528\u666e\u901a\u7528\u6237\u767b\u5f55\uff0c\u5728\u9700\u8981\u6267\u884c\u66f4\u9ad8\u6743\u9650\u547d\u4ee4\u65f6\uff0c\u901a\u8fc7 sudo \u547d\u4ee4\uff0c\u6216\u8005 su \u6210 root \u518d\u6267\u884c\u3002<\/p>\n<p><strong>\u9650\u5236\u8d26\u53f7\u591a\u91cd\u767b\u9646<\/strong><\/p>\n<p>\u8fd9\u6837\u7684\u505a\u6cd5\uff0c\u80fd\u8ba9\u540c\u4e00\u4e2a\u8d26\u53f7\uff0c\u5728\u540c\u4e00\u65f6\u95f4\u5185\u4e0d\u80fd\u88ab\u591a\u4eba\u540c\u65f6\u767b\u5f55\u3002<br \/>\n\u5b9e\u73b0\u65b9\u6cd5\uff1a\u7f16\u8f91 \/etc\/security\/limits.conf<br \/>\n\u52a0\u5165\u5982\u4e0b\u914d\u7f6e\u9879\u5373\u53ef\uff1a<br \/>\n*               hard    maxlogins       2<\/p>\n<p><strong>\u9632 ping<\/strong><br \/>\n# \u7981\u6b62 ping<br \/>\necho 1 > \/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all<br \/>\n# \u5141\u8bb8 ping<br \/>\necho 0 > \/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all<\/p>\n<p><strong>\u4e00\u3001\u751f\u6210\u5bc6\u94a5\u5bf9<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c ssh-keygen \u751f\u6210\uff08RSA\/DSA \u4e8c\u9009\u4e00\uff09\uff1a<br \/>\n# RSA<br \/>\nssh-keygen -t rsa -b 2048 -C kiccleaf@163.com<br \/>\n# DSA<br \/>\nssh-keygen -t dsa -C kiccleaf@163.com<\/p>\n<p>\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528 putty \u7684 puttygen \u5de5\u5177\u751f\u6210\u3002<br \/>\nSSH \u767b\u5f55\u9700\u8981 OpenSSH \u683c\u5f0f\u7684\u516c\u94a5\uff0cssh-keygen \u751f\u6210\u7684 id_rsa.pub \/ id_dsa.pub \u5c31\u662f\u8fd9\u79cd\u683c\u5f0f\uff0c\u5982\u679c\u662f\u7528 puttygen \u751f\u6210\uff0c\u9700\u8981\u5bfc\u51fa\u4e3a OpenSSH \u683c\u5f0f\u3002<\/p>\n<p><strong>\u4e8c\u3001\u6dfb\u52a0\u670d\u52a1\u7aef\u516c\u94a5<\/strong><br \/>\n\u7528\u5c06\u8981\u4f7f\u7528\u5bc6\u94a5\u7684\u7528\u6237\u767b\u5f55 VPS\u3002<br \/>\ncd<br \/>\nmkdir -p .ssh<br \/>\nchmod 755 .ssh<\/p>\n<p># RSA<br \/>\ncat id_rsa.pub >> .ssh\/authorized_keys<br \/>\n# RSA<br \/>\ncat id_dsa.pub >> .ssh\/authorized_keys2<\/p>\n<p>chmod 644 .ssh\/authorized_keys<\/p>\n<p><strong>\u4e09\u3001\u914d\u7f6e SSH \u670d\u52a1\u7aef<\/strong><\/p>\n<p>\u7f16\u8f91 \/etc\/ssh\/sshd_config\uff0c\u4fee\u6539\u4ee5\u4e0b\u51e0\u4e2a\u53c2\u6570\uff0c\u7981\u6b62 root \u8d26\u53f7 \u548c \u4f7f\u7528\u5bc6\u7801 \u76f4\u63a5\u767b\u5f55\uff1a<\/p>\n<p>PermitRootLogin no<br \/>\nPasswordAuthentication no<\/p>\n<p>\u91cd\u542f SSH \u670d\u52a1\uff1a<br \/>\n\/etc\/init.d\/sshd restart<\/p>\n<p><strong>\u56db\u3001\u914d\u7f6e SSH \u5ba2\u6237\u7aef<\/strong><\/p>\n<p>SecureCRT \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 OpenSSH \u683c\u5f0f\u7684\u5bc6\u94a5\uff0cputty \u5219\u9700\u8981\u4f7f\u7528 puttygen \u5bfc\u5165 id_rsa \/ id_dsa \u518d\u4fdd\u5b58\u4e3a .ppk \u683c\u5f0f\u7684\u79c1\u94a5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3 \u4e0d\u8981\u4f7f\u7528\u9ed8\u8ba4\u7684 22 \u7aef\u53e3&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"http:\/\/www.kiccleaf.com\/?p=229\">Continue reading<span class=\"screen-reader-text\">\u6574\u7406\u4e86\u4e00\u4efdVPS \u5b89\u5168\u8bbe\u7f6e<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[4],"tags":[13,43,21,44],"class_list":["post-229","post","type-post","status-publish","format-standard","hentry","category-linux-","tag-linux","tag-vps","tag-21","tag-44","entry"],"views":3234,"_links":{"self":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=229"}],"version-history":[{"count":0,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/229\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}