{"id":645,"date":"2022-10-08T13:05:34","date_gmt":"2022-10-08T05:05:34","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=645"},"modified":"2024-07-08T12:50:13","modified_gmt":"2024-07-08T04:50:13","slug":"linux%e9%99%90%e5%88%b6%e6%9f%90%e4%ba%9b%e7%94%a8%e6%88%b7%e6%88%96ip%e7%99%bb%e5%bd%95ssh%e3%80%81%e5%85%81%e8%ae%b8%e7%89%b9%e5%ae%9aip%e7%99%bb%e5%bd%95ssh","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2022\/10\/08\/linux%e9%99%90%e5%88%b6%e6%9f%90%e4%ba%9b%e7%94%a8%e6%88%b7%e6%88%96ip%e7%99%bb%e5%bd%95ssh%e3%80%81%e5%85%81%e8%ae%b8%e7%89%b9%e5%ae%9aip%e7%99%bb%e5%bd%95ssh\/","title":{"rendered":"Linux\u9650\u5236\u67d0\u4e9b\u7528\u6237\u6216IP\u767b\u5f55SSH\u3001\u5141\u8bb8\u7279\u5b9aIP\u767b\u5f55SSH"},"content":{"rendered":"<p>\u914d\u7f6e\u670d\u52a1\u5668\u7684SSH\uff1a<\/p>\n<p>1\u3001\u9650\u5236\u7528\u6237SSH\u767b\u5f55<\/p>\n<p>\u53ea\u5141\u8bb8\u6307\u5b9a\u7528\u6237\u8fdb\u884c\u767b\u5f55\uff08\u767d\u540d\u5355\uff09\uff1a<\/p>\n<p>\u5728\/etc\/ssh\/sshd_config\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6eAllowUsers\u9009\u9879\uff0c\uff08\u914d\u7f6e\u5b8c\u6210\u9700\u8981\u91cd\u542f SSHD \u670d\u52a1\uff09\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>AllowUsers aliyun test@192.168.1.1<br \/>\n# \u5141\u8bb8 aliyun \u548c\u4ece 192.168.1.1 \u767b\u5f55\u7684 test \u5e10\u6237\u901a\u8fc7 SSH \u767b\u5f55\u7cfb\u7edf\u3002<br \/>\n\u53ea\u62d2\u7edd\u6307\u5b9a\u7528\u6237\u8fdb\u884c\u767b\u5f55\uff08\u9ed1\u540d\u5355\uff09\uff1a<\/p>\n<p>\u5728\/etc\/ssh\/sshd_config\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6eDenyUsers\u9009\u9879\uff0c\uff08\u914d\u7f6e\u5b8c\u6210\u9700\u8981\u91cd\u542fSSHD\u670d\u52a1\uff09\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>DenyUsers zhangsan aliyun #Linux\u7cfb\u7edf\u8d26\u6237<br \/>\n# \u62d2\u7edd zhangsan\u3001aliyun \u5e10\u6237\u901a\u8fc7 SSH \u767b\u5f55\u7cfb\u7edf<br \/>\n\u91cd\u542fSSH<\/p>\n<p>service sshd restart<br \/>\n2\u3001\u9650\u5236IP SSH\u767b\u5f55<\/p>\n<p>\u8bf4\u660e\uff1a\u8fd9\u91cc\u7684IP\u662f\u6307\u5ba2\u6237\u7aefIP\uff0c\u4e0d\u662f\u670d\u52a1\u5668IP\uff0c\u4e0b\u9762\u7684\u4f8b\u5b50\u4f7f\u7528\u4e86hosts.allow\u6587\u4ef6\u7684\u914d\u7f6e\u65b9\u5f0f\uff0c\u76ee\u7684\u662f\u5feb\uff0c\u4f46\u4e5f\u6709\u4e0d\u7075\u6d3b\u7684\uff0c\u5efa\u8bae\u6539\u6210iptables\u7684\u65b9\u6848\u3002<\/p>\n<p>\u9664\u4e86\u53ef\u4ee5\u7981\u6b62\u67d0\u4e2a\u7528\u6237\u767b\u5f55\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u9488\u5bf9\u56fa\u5b9a\u7684IP\u8fdb\u884c\u7981\u6b62\u767b\u5f55\uff0clinux \u670d\u52a1\u5668\u901a\u8fc7\u8bbe\u7f6e\/etc\/hosts.allow\u548c\/etc\/hosts.deny\u8fd9\u4e2a\u4e24\u4e2a\u6587\u4ef6\uff0chosts.allow\u8bb8\u53ef\u5927\u4e8ehosts.deny\u53ef\u4ee5\u9650\u5236\u6216\u8005\u5141\u8bb8\u67d0\u4e2a\u6216\u8005\u67d0\u6bb5IP\u5730\u5740\u8fdc\u7a0b SSH \u767b\u5f55\u670d\u52a1\u5668\uff0c\u65b9\u6cd5\u6bd4\u8f83\u7b80\u5355\uff0c\u4e14\u8bbe\u7f6e\u540e\u7acb\u5373\u751f\u6548\uff0c\u4e0d\u9700\u8981\u91cd\u542fSSHD\u670d\u52a1\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<p>\/etc\/hosts.allow\u6dfb\u52a0<\/p>\n<p>sshd:192.168.0.1:allow #\u5141\u8bb8 192.168.0.1 \u8fd9\u4e2aIP\u5730\u5740SSH\u767b\u5f55<br \/>\nsshd:192.168.0.:allow #\u5141\u8bb8192.168.0.1\/24\u8fd9\u6bb5IP\u5730\u5740\u7684\u7528\u6237\u767b\u5f55\uff0c\u591a\u4e2a\u7f51\u6bb5\u53ef\u4ee5\u4ee5\u9017\u53f7\u9694\u5f00\uff0c\u6bd4\u5982192.168.0.,192.168.1.:allow<br \/>\n\/etc\/hosts.allow\u6dfb\u52a0<\/p>\n<p>sshd:ALL #\u5141\u8bb8\u5168\u90e8\u7684ssh\u767b\u5f55<br \/>\nhosts.allow\u548chosts.deny\u4e24\u4e2a\u6587\u4ef6\u540c\u65f6\u8bbe\u7f6e\u89c4\u5219\u7684\u65f6\u5019\uff0chosts.allow\u6587\u4ef6\u4e2d\u7684\u89c4\u5219\u4f18\u5148\u7ea7\u9ad8\uff0c\u6309\u7167\u6b64\u65b9\u6cd5\u8bbe\u7f6e\u540e\u670d\u52a1\u5668\u53ea\u5141\u8bb8192.168.0.1\u8fd9\u4e2aIP\u5730\u5740\u7684SSH\u767b\u5f55\uff0c\u5176\u5b83\u7684IP\u90fd\u4f1a\u62d2\u7edd\u3002<\/p>\n<p>\/etc\/hosts.deny\u6dfb\u52a0<\/p>\n<p>sshd:ALL #\u62d2\u7edd\u5168\u90e8IP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u7f6e\u670d\u52a1\u5668\u7684SSH\uff1a 1\u3001\u9650\u5236\u7528\u6237SSH\u767b\u5f55 \u53ea\u5141\u8bb8\u6307\u5b9a\u7528\u6237&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-645","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=645"}],"version-history":[{"count":1,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/645\/revisions"}],"predecessor-version":[{"id":1203,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/645\/revisions\/1203"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}