{"id":152,"date":"2022-05-26T12:20:22","date_gmt":"2022-05-26T12:20:22","guid":{"rendered":"https:\/\/vitorprado.com\/?p=152"},"modified":"2023-01-26T20:18:39","modified_gmt":"2023-01-26T20:18:39","slug":"configuring-ssh-securely-the-correct-way","status":"publish","type":"post","link":"https:\/\/vitorprado.com\/?p=152","title":{"rendered":"Configuring SSH securely (the correct way)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">First step, install OpenSSH. On Ubuntu you can use <code>\"sudo apt install openssh-server\"<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Edit file <em>&#8220;\/etc\/hosts.allow&#8221;<\/em> and allow only specific IPs or network to access over ssh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example (network 192.168.0.0\/24)\nsshd: 192.168.0.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Block all another IPs editing <em>&#8220;\/etc\/hosts.deny&#8221;<\/em> with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sshd: ALL<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Edit file <em>&#8220;\/etc\/ssh\/sshd_config&#8221;<\/em> and include this role:\u00a0 <em>&#8220;PermitRootLogin no&#8221;<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install UFW firewall, allow SSH connections and enable firewall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install ufw\nsudo ufw allow ssh\nsudo ufw enable<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First step, install OpenSSH. On Ubuntu you can use &#8220;sudo apt install openssh-server&#8221; Edit file &#8220;\/etc\/hosts.allow&#8221; and allow only specific IPs or network to access over ssh. Block all another IPs editing &#8220;\/etc\/hosts.deny&#8221; with: Edit file &#8220;\/etc\/ssh\/sshd_config&#8221; and include this role:\u00a0 &#8220;PermitRootLogin no&#8221; Install UFW firewall, allow SSH connections and enable firewall:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"blank","format":"standard","meta":{"footnotes":""},"categories":[12,11],"tags":[24,17,18],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-cloud","category-software","tag-cloud","tag-linux","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vitorprado.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":1,"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/vitorprado.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/vitorprado.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vitorprado.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vitorprado.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}