{"id":134,"date":"2024-01-28T14:31:44","date_gmt":"2024-01-28T14:31:44","guid":{"rendered":"https:\/\/www.wdh.fr\/blog\/?p=134"},"modified":"2024-03-11T04:09:40","modified_gmt":"2024-03-11T04:09:40","slug":"securing-ssh-access-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.wdh.fr\/blog\/en\/securing-ssh-access-a-step-by-step-guide\/","title":{"rendered":"Securing SSH Access: A Step-by-Step Guide"},"content":{"rendered":"\n<p>In this FAQ, we will explore several solutions to secure your SSH access.<\/p>\n\n\n\n<p>Using Secure Passwords:<\/p>\n\n\n\n<p>One of the best practices to enhance security across your accesses is to use complex passwords.<\/p>\n\n\n\n<p>Here are some password guidelines:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Never use the same password for different accesses.<\/li>\n\n\n\n<li>Use at least 10 characters.<\/li>\n\n\n\n<li>Include at least one uppercase letter.<\/li>\n\n\n\n<li>Include at least one special character.<\/li>\n<\/ul>\n\n\n\n<p>Changing the SSH Port:<\/p>\n\n\n\n<p>To make SSH access more challenging, consider changing the default port of the SSH service.<\/p>\n\n\n\n<p>First, edit the file \/etc\/ssh\/sshd_config (replace XXXX with the desired port):<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><code>\/etc\/ssh\/sshd_config<\/code><\/p>\n\n\n\n<p><code>#Port 22<\/code><\/p>\n\n\n\n<p><code>Port XXXX<\/code><\/p>\n\n\n\n<p>Then, restart your SSH service:<\/p>\n\n\n\n<p><code>#service ssh restart<\/code><\/p>\n\n\n\n<p>If you&#8217;re using Putty to connect, simply adjust the port in the connection settings. For Linux users, utilize the following command to connect:<\/p>\n\n\n\n<p><code>ssh root@YOUR_IP -p XXXX<\/code><\/p>\n\n\n\n<p>Changing the SSH port also changes the SFTP port.<\/p>\n\n\n\n<p>Disabling root SSH Access:<\/p>\n\n\n\n<p>During an attack, the root user is often the primary target due to its extensive server access. Hence, it&#8217;s essential to restrict root access from external sources. Users should connect to the server with another account before accessing the root account.<\/p>\n\n\n\n<p>Create a new user for SSH access (replace USER with your username):<\/p>\n\n\n\n<p><code>adduser USER<\/code><\/p>\n\n\n\n<p>Modify the file \/etc\/ssh\/sshd_config:<\/p>\n\n\n\n<p><code>\/etc\/ssh\/sshd_config<\/code><\/p>\n\n\n\n<p><code>#PermitRootLogin yes<\/code><\/p>\n\n\n\n<p><code>PermitRootLogin no<\/code><\/p>\n\n\n\n<p><code>AllowUsers USER<\/code><\/p>\n\n\n\n<p>Then, restart your SSH service:<\/p>\n\n\n\n<p><code>#service ssh restart<\/code><\/p>\n\n\n\n<p>To connect via Putty, adjust the username in the connection settings. For Linux users, use the following command:<\/p>\n\n\n\n<p><code>ssh USER@YOUR_IP -p XXXX<\/code><\/p>\n\n\n\n<p>Once connected with the alternate user, you can switch to the root user using the following command:<\/p>\n\n\n\n<p><code>su -<\/code><\/p>\n\n\n\n<p>Installing Fail2ban:<\/p>\n\n\n\n<p>Fail2ban detects suspicious SSH connection attempts and blocks them.<\/p>\n\n\n\n<p>To install Fail2ban, execute the following command:<\/p>\n\n\n\n<p><code>apt-get install fail2ban<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this FAQ, we will explore several solutions to secure your SSH access. Using Secure Passwords: One of the best practices to enhance security across your accesses is to use complex passwords. Here are some password guidelines: Changing the SSH Port: To make SSH access more challenging, consider changing the default port of the SSH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/134"}],"collection":[{"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/comments?post=134"}],"version-history":[{"count":1,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/134\/revisions"}],"predecessor-version":[{"id":135,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/134\/revisions\/135"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/media\/132"}],"wp:attachment":[{"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/media?parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/categories?post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wdh.fr\/blog\/en\/wp-json\/wp\/v2\/tags?post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}