{"id":97979,"date":"2024-06-17T19:05:10","date_gmt":"2024-06-17T11:05:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=97979"},"modified":"2024-06-17T19:05:10","modified_gmt":"2024-06-17T11:05:10","slug":"safer-ubuntu16","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/safer-ubuntu16.html","title":{"rendered":"\u53ea\u8981\u4e94\u62db\uff01\u8ba9\u4f60\u7684Ubuntu 16.04\u66f4\u5b89\u5168"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nUbuntu 16.04\u7684\u5b89\u88c5\u76f8\u5bf9\u7b80\u5355\uff0c\u5b89\u88c5\u4e4b\u540e\uff0c\u4f60\u5c06\u4eab\u53d7Linux\u5e26\u6765\u7684\u5b89\u5168\u6027\u3002\u5b9e\u9645\u4e0a\u4e3a\u4e86\u63d0\u9ad8\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u4f60\u8fd8\u53ef\u4ee5\u505a\u7684\u66f4\u591a\uff0c\u4e0b\u9762\u76845\u62db\u5c06\u7ed9\u4f60\u5e26\u6765\u4e0d\u9519\u7684\u5b89\u5168\u6536\u76ca\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5982\u679c\u60f3\u8ba9Ubuntu\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u80fd\u4e0a\u5347\u4e00\u4e2a\u5c42\u6b21\u7684\u8bdd\uff0c\u8bf7\u4ed4\u7ec6\u9605\u8bfb\u4e0b\u9762\u76845\u62db\u3002<\/p>\n

Ubuntu 16.04\u7684\u5b89\u88c5\u76f8\u5bf9\u7b80\u5355\uff0c\u5b89\u88c5\u4e4b\u540e\uff0c\u4f60\u5c06\u4eab\u53d7Linux\u5e26\u6765\u7684\u5b89\u5168\u6027\u3002\u5b9e\u9645\u4e0a\u4e3a\u4e86\u63d0\u9ad8\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u4f60\u8fd8\u53ef\u4ee5\u505a\u7684\u66f4\u591a\uff0c\u4e0b\u9762\u76845\u62db\u5c06\u7ed9\u4f60\u5e26\u6765\u4e0d\u9519\u7684\u5b89\u5168\u6536\u76ca\u3002<\/p>\n

1.\u786e\u4fdd\u5171\u4eab\u5185\u5b58\u7684\u5b89\u5168<\/strong><\/div>\n

\u9ed1\u5ba2\u653b\u51fb\u603b\u4f1a\u60f3\u67e5\u770b\u5171\u4eab\u5185\u5b58\uff0c\u6240\u4ee5\u4fdd\u8bc1\u5171\u4eab\u5185\u5b58\u7684\u5b89\u5168\u7684\u91cd\u8981\u6027\u4e0d\u8a00\u800c\u55bb\u3002\u53ef\u4ee5\u4fee\u6539 \/etc\/fstab\u6587\u4ef6\u6765\u786e\u4fdd\u5171\u4eab\u5185\u5b58\u7684\u5b89\u5168\u3002<\/p>\n

\u9996\u5148\uff0c\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u6253\u5f00\u6587\u4ef6<\/p>\n

sudo nano \/etc\/fstab <\/pre>\n

\u7136\u540e\uff0c\u6587\u4ef6\u7684\u5e95\u90e8\u52a0\u5165\u5982\u4e0b\u4ee3\u7801<\/p>\n

tmpfs \/run\/shm tmpfs defaults,noexec,nosuid 0 0 <\/pre>\n

\u4fdd\u5b58\uff0c\u5173\u95ed\u6587\u4ef6\u3002\u4e3a\u4e86\u4f7f\u6539\u53d8\u751f\u6548\uff0c\u9700\u8981\u91cd\u542fUbuntu 16.04.
\n\"\"<\/p>\n

2.\u5141\u8bb8\u7279\u5b9a\u7528\u6237\u7684ssh\u767b\u5f55<\/strong><\/div>\n

\u5047\u5982\u8bf4\u4f60\u53ea\u60f3\u7528\u6237\u540d\u4e3aolivia\uff0cIP\u5730\u5740\u4e3a192.168.1.152\u7684\u7528\u6237\u901a\u8fc7secure shell\uff0c\u505a\u6cd5\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n

1.\u6253\u5f00\u7ec8\u7aef\u547d\u4ee4\u7a97\u53e3<\/p>\n

2.\u4f7f\u7528\u547d\u4ee4\u6253\u5f00ssh\u914d\u7f6e\u6587\u4ef6<\/p>\n

sudo nano \/etc\/ssh\/sshd_config <\/pre>\n

3.\u5728\u6587\u4ef6\u6700\u4e0b\u9762\uff0c\u6dfb\u52a0AllowUsers olivia@192.168.1.152<\/p>\n

4.\u4fdd\u5b58\uff0c\u5173\u95ed\u6587\u4ef6<\/p>\n

5.\u4f7f\u7528\u547d\u4ee4\u91cd\u542fsshd<\/p>\n

sudo service ssh restart <\/pre>\n

\u5230\u8fd9\u91cc\uff0csecure shell\u53ea\u4f1a\u8ba9IP\u5730\u5740\u4e3a192.168.1.152\u7684olivia\u83b7\u5f97\u8bbf\u95eeUbuntu\u670d\u52a1\u5668\u7684\u6743\u9650\u3002\u5982\u679c\u5176\u4ed6\u4eba\u5c1d\u8bd5\u4f7f\u7528ssh\u8bbf\u95ee\u670d\u52a1\u5668\uff0c\u4ed6\u4eec\u4f1a\u88ab\u8981\u6c42\u8f93\u5165\u5bc6\u7801\uff0c\u4f46\u662f\u5373\u4f7f\u5bc6\u7801\u6b63\u786e\uff0c\u8bbf\u95eeUbuntu\u670d\u52a1\u5668\u4e5f\u4f1a\u88ab\u62d2\u7edd\u3002<\/p>\n

\u5047\u5982\uff0c\u4f60\u60f3\u8ba9\u4f60\u7684\u7f51\u7edc\u4e0b\u7684\u6240\u6709\u7528\u6237\u90fd\u80fd\u901a\u8fc7ssh\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u8bdd\uff0c\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801<\/p>\n

AllowUsers *@192.168.1.*<\/p>\n

\u91cd\u542fssh\u670d\u52a1\u5668\uff0c\u5c31\u751f\u6548\u4e86\u3002<\/p>\n

3.\u6dfb\u52a0\u4e00\u4e2a\u5b89\u5168\u767b\u5f55banner<\/strong><\/div>\n

\u6dfb\u52a0\u4e00\u4e2a\u5b89\u5168\u767b\u5f55bannner\u4f3c\u4e4e\u5bf9\u4f60\u7684\u670d\u52a1\u5668\u5b89\u5168\u6ca1\u6709\u4ec0\u4e48\u4f5c\u7528\uff0c\u4f46\u662f\u5047\u5982\u6709\u4eba\u83b7\u5f97\u8bbf\u95ee\u4f60\u670d\u52a1\u5668\u7684\u6743\u9650\u540e\uff0c\u770b\u5230\u4e86banner\u4e0a\u7684\u8b66\u544a\u4fe1\u606f\uff0c\u53ef\u80fd\u4f1a\u601d\u8003\u518d\u4e09\u8981\u4e0d\u8981\u7ee7\u7eed\u4e0b\u53bb\u3002\u867d\u7136\u8fd9\u662f\u4e00\u79cd\u5fc3\u91cc\u4f5c\u7528\uff0c\u4f46\u662f\u4e5f\u4e0d\u8981\u5c0f\u77a7\u4e86\u5b83\u3002<\/p>\n

\u521b\u5efa\u4e00\u4e2a\u65b0\u7684banner\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

1.\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3<\/p>\n

2.\u6267\u884c\u547d\u4ee4<\/p>\n

sudo nano \/etc\/issue.net <\/pre>\n

3.\u6dfb\u52a0\u5408\u9002\u7684\u8b66\u544a\u4fe1\u606f<\/p>\n

4.\u5173\u95ed\uff0c\u4fdd\u5b58\u6587\u4ef6<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8981\u7981\u6b62motd\u663e\u793abanner\u3002\u9996\u5148\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/p>\n

sudo nano \/etc\/pam.d\/sshd <\/pre>\n

\u52a0\u5165\u4e0b\u9762\u4e24\u884c\uff08\u6bcf\u884c\u524d\u52a0#\uff09<\/p>\n

session optional pam_motd.so motd=\/run\/motd.dynamic  \r\nsession optional pam_motd.so noupdate <\/pre>\n

\u5728\u6587\u672c\u7f16\u8f91\u5668\u91cc\u6253\u5f00 \/etc\/ssh\/sshd_config\u6587\u4ef6\uff0c\u52a0\u5165<\/p>\n

Banner \/etc\/issue.net <\/pre>\n

\u5173\u95ed\uff0c\u4fdd\u5b58\u6587\u4ef6<\/p>\n

\u6700\u540e\uff0c\u4f7f\u7528\u547d\u4ee4\u91cd\u542fssh\u670d\u52a1\u5668<\/p>\n

sudo service ssh restart <\/pre>\n

\u8fd9\u65f6\uff0c\u5047\u5982\u6709\u4eba\u901a\u8fc7ssh\u767b\u5f55\u4f60\u7684\u670d\u52a1\u5668\uff0c\u4ed6\u4eec\u5c31\u4f1a\u770b\u5230\u4f60\u65b0\u52a0\u7684banner\uff0c\u8b66\u544a\u4ed6\u4eec\u4f60\u5728\u7559\u610f\u3002<\/p>\n

4.\u589e\u5f3a\u7f51\u7edc\u5c42<\/strong><\/div>\n

\u4e3a\u907f\u514d\u4f60\u7684Ubuntu\u670d\u52a1\u5668\u4e0a\u6e90\u8def\u7531\u8f93\u5165\u5305\uff0c\u5e76\u4e14\u6253\u5370\u51fa\u6240\u6709\u7578\u5f62IP\u5730\u5740,\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<\/p>\n

sudo nano \/etc\/sysctl.conf <\/pre>\n

\u7136\u540e\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9<\/p>\n

\r\n# IP Spoofing protection \r\nnet.ipv4.conf.all.rp_filter = 1 \r\nnet.ipv4.conf.default.rp_filter = 1 \r\n# Ignore ICMP broadcast requests \r\nnet.ipv4.icmp_echo_ignore_broadcasts = 1 \r\n# Disable source packet routing \r\nnet.ipv4.conf.all.accept_source_route = 0 \r\nnet.ipv6.conf.all.accept_source_route = 0  \r\nnet.ipv4.conf.default.accept_source_route = 0 \r\nnet.ipv6.conf.default.accept_source_route = 0 \r\n# Ignore send redirects \r\nnet.ipv4.conf.all.send_redirects = 0 \r\nnet.ipv4.conf.default.send_redirects = 0 \r\n# Block SYN attacks \r\nnet.ipv4.tcp_syncookies = 1 \r\nnet.ipv4.tcp_max_syn_backlog = 2048 \r\nnet.ipv4.tcp_synack_retries = 2 \r\nnet.ipv4.tcp_syn_retries = 5 \r\n# Log Martians \r\nnet.ipv4.conf.all.log_martians = 1 \r\nnet.ipv4.icmp_ignore_bogus_error_responses = 1 \r\n# Ignore ICMP redirects \r\nnet.ipv4.conf.all.accept_redirects = 0 \r\nnet.ipv6.conf.all.accept_redirects = 0 \r\nnet.ipv4.conf.default.accept_redirects = 0  \r\nnet.ipv6.conf.default.accept_redirects = 0 \r\n# Ignore Directed pings \r\nnet.ipv4.icmp_echo_ignore_all = 1 \r\n<\/pre>\n

\u5173\u95ed\uff0c\u4fdd\u5b58\u6587\u4ef6\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u91cd\u542f\u3002<\/p>\n

sudo sysctl -p <\/pre>\n
5.\u907f\u514dIP\u5730\u5740\u6b3a\u9a97<\/strong><\/div>\n

\u63a5\u4e0b\u6765\u901a\u8fc7\u7b80\u5355\u7684\u64cd\u4f5c\u5c31\u53ef\u4ee5\u907f\u514dIP\u5730\u5740\u6b3a\u9a97\u3002\u4f7f\u7528\u5982\u4e0b\u7ec8\u7aef\u547d\u4ee4\uff1a<\/p>\n

sudo nano \/etc\/host.conf <\/pre>\n

\u6253\u5f00\u4e4b\u540e\u7684\u6587\u4ef6\u662f\u50cf\u8fd9\u6837\u7684\uff1a<\/p>\n

\r\n# The \"order\" line is only used by old versions of the C library. \r\norder hosts,bind \r\nmulti on \r\n<\/pre>\n

\u66f4\u6539\u8fd9\u4e2a\u6587\u4ef6\u4e3a\uff1a<\/p>\n

\r\n# The \"order\" line is only used by old versions of the C library. \r\norder bind,hosts \r\nnospoof on \r\n<\/pre>\n

\u4fdd\u5b58\uff0c\u5173\u95ed\u6587\u4ef6\uff0c\u73b0\u5728\u4e0d\u4f1a\u6709IP\u5730\u5740\u6b3a\u9a97\u4e86\u3002<\/p>\n

\u7ed3\u675f\u8bed\uff1a\u6211\u4eec\u53ea\u662f\u4ece\u8f83\u6d45\u7684\u89d2\u5ea6\u589e\u5f3a\u4f60\u7684Ubuntu 16.04\uff0c\u4f46\u662f\u8fd95\u62db\u80fd\u663e\u8457\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002\u540e\u7eed\u6211\u4eec\u4f1a\u7ee7\u7eed\u5173\u6ce8\u8fd9\u4e00\u8bdd\u9898\uff0c\u5e26\u6765\u66f4\u5b89\u5168\u7684Ubuntu\u5e73\u53f0\u5b89\u5168\u653b\u7565\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/server.51cto.com\/sOS-568665.htm<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/safer-ubuntu16.html<\/a>\u7f16\u8f91\uff1a\u70e8\u5b50\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Ubuntu 16.04\u7684\u5b89\u88c5\u76f8\u5bf9\u7b80\u5355\uff0c\u5b89\u88c5\u4e4b\u540e\uff0c\u4f60\u5c06\u4eab\u53d7Linux\u5e26\u6765\u7684\u5b89\u5168\u6027\u3002\u5b9e\u9645\u4e0a\u4e3a\u4e86\u63d0\u9ad8\u6570\u636e\u7684\u5b89 […]<\/p>\n","protected":false},"author":63,"featured_media":84704,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-97979","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/97979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=97979"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/97979\/revisions"}],"predecessor-version":[{"id":291995,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/97979\/revisions\/291995"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/84704"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=97979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=97979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=97979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}