{"id":1177,"date":"2024-07-05T06:38:08","date_gmt":"2024-07-05T06:38:08","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=1177"},"modified":"2024-07-05T06:38:08","modified_gmt":"2024-07-05T06:38:08","slug":"can-i-limit-the-ips-that-sshd-listens-on","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/can-i-limit-the-ips-that-sshd-listens-on.html","title":{"rendered":"Can I Limit the IP(s) that sshd Listens On?"},"content":{"rendered":"<p>To limit the IP addresses which sshd listens on, you just need to modify its settings within the <strong>sshd_config<\/strong>file. Follow these 4 easy steps:<\/p>\n<ol>\n<li>First, backup the <strong>sshd_config<\/strong> file, then edit it with your favorite editor.<\/li>\n<li>Now, to limit the IPs sshd listens on, you need to change the <strong>ListenAddress<\/strong> configuration line:<em>root@root [~]# cd \/etc\/ssh\/<\/em><br \/>\n<em>root@root [\/etc\/ssh]# cp sshd_config sshd_config.save<\/em><br \/>\n<em>root@root [\/etc\/ssh]# vi sshd_config<\/em><br \/>\n<em>root@root [\/etc\/ssh]# diff sshd_config sshd_config.save<\/em><br \/>\n<em>15c15<\/em><br \/>\n<em>&lt; ListenAddress 10.0.0.1<\/em><br \/>\n<em>\u2014<\/em><br \/>\n<em>&gt; #ListenAddress 0.0.0.0<\/em><\/li>\n<li>Next, restart sshd and verify that it\u2019s listening on the specified address:<em>root@root [\/etc\/ssh]# \/etc\/init.d\/sshd restart<\/em><br \/>\n<em>Stopping sshd: [ OK ]<\/em><br \/>\n<em>Starting sshd: [ OK ]<\/em><br \/>\n<em>root@root [\/etc\/ssh]# netstat -anp | grep sshd<\/em><br \/>\n<em>tcp 0 0 10.0.0.1:22 0.0.0.0:* LISTEN 1718\/sshd<\/em><\/li>\n<li>If you want sshd to listen on more than one address, then add additional <em>ListenAddress<\/em> lines to the configuration file:<em>root@root [\/etc\/ssh]# diff sshd_config sshd_config.save<\/em><br \/>\n<em>15,16c15<\/em><br \/>\n<em>&lt; ListenAddress 10.0.0.1<\/em><br \/>\n<em>&lt; ListenAddress 10.0.0.2<\/em><br \/>\n<em>\u2014<\/em><br \/>\n<em>&gt; #ListenAddress 0.0.0.0<\/em><\/p>\n<p><em>root@root [\/etc\/ssh]# \/etc\/init.d\/sshd restart<\/em><br \/>\n<em>Stopping sshd: [ OK ]<\/em><br \/>\n<em>Starting sshd: [ OK ]<\/em><br \/>\n<em>root@root [\/etc\/ssh]# netstat -anp | grep sshd<\/em><br \/>\n<em>tcp 0 0 10.0.0.1:22 0.0.0.0:* LISTEN 1884\/sshd<\/em><br \/>\n<em>tcp 0 0 10.0.0.2:22 0.0.0.0:* LISTEN 1884\/sshd<\/em><\/li>\n<\/ol>\n<p>And there you have it!<\/p>\n<div class=\"tjizo69e76d00e80e1\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.tjizo69e76d00e80e1 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.tjizo69e76d00e80e1 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.tjizo69e76d00e80e1 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.tjizo69e76d00e80e1 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.tjizo69e76d00e80e1 {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>To limit the IP addresses which sshd listens on, you just need to modify its settings within the sshd_configfile. Follow these 4 easy steps: First, backup the sshd_config file, then edit it with your favorite editor. Now, to limit the IPs sshd listens on, you need to change the ListenAddress configuration line:root@root [~]# cd \/etc\/ssh\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1177","post","type-post","status-publish","format-standard","hentry","category-server-setup"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/1177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=1177"}],"version-history":[{"count":2,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/1177\/revisions"}],"predecessor-version":[{"id":1179,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/1177\/revisions\/1179"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=1177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=1177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=1177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}