{"id":365,"date":"2019-05-13T16:55:11","date_gmt":"2019-05-13T16:55:11","guid":{"rendered":"https:\/\/unsrewiki.1sys1.com\/?p=365"},"modified":"2019-05-13T16:55:11","modified_gmt":"2019-05-13T16:55:11","slug":"securing-ssh-login","status":"publish","type":"post","link":"https:\/\/server-help.org\/index.php\/2019\/05\/13\/securing-ssh-login\/","title":{"rendered":"Securing SSH Login"},"content":{"rendered":"\n<p>*UNIX Servers, like any Device once it&#8217;s connected to the Internet, it could be under any Cyber Attacks. In this article, we will try to reach Best Practice Security methods, in order to secure our Server(s) login from non-authorized users.<\/p>\n\n\n\n<p>First, when you access your *UNIX Server, it may show you the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Last failed login: Sat May  4 14:08:36 UTC 2019 from 58.242.82.9 on ssh:notty\nThere were 9030 failed login attempts since the last successful login.\nLast login: Fri May  3 05:34:33 2019 from c-73-13-124-20.hsd1.XX.XXXXXX.net<\/code><\/pre>\n\n\n\n<p>As we can see, from these Information, there were 9030 tries to access our Server using username <strong>root<\/strong>, and the default port for SSH <strong>port 22<\/strong>. Hence, we need to change these settings. Let&#8217;s get started.<\/p>\n\n\n\n<p>Open the SSH configuration file in any text editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># vi \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p>Withing sshd_config, we are going to uncomment Port 22, and change 22 to whatever unassigned port number (you can choose between  1-65535 ).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Port &lt;any_number><\/code><\/pre>\n\n\n\n<p>After changing the Default Port number, we need to disable root user from login to the server remotely. uncomment<strong> PermitRootLogin yes<\/strong> and change it to <strong>no<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PermitRootLogin no<\/code><\/pre>\n\n\n\n<p>Once we disable root from Login, we need to create and allow another user(s), to access the Server remotely. By adding <strong>AllowUsers <\/strong>to your SSH Configuration file under <strong>Authentication <\/strong>Section: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Authentication:\n\nAllowUsers &lt;username><\/code><\/pre>\n\n\n\n<p>Save SSH Configuration File, and restart SSH service.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># systemctl restart sshd\nor\n# service ssh restart<\/code><\/pre>\n\n\n\n<p>Now, we are not able to login to our Server using root user, therefore, we need to login with user we have added to <strong>AllowUsers <\/strong>section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>*UNIX Servers, like any Device once it&#8217;s connected to the Internet, it could be under any Cyber Attacks. In this article, we will try to reach Best Practice Security methods, in order to secure our Server(s) login from non-authorized users. First, when you access your *UNIX Server, it may show you the following: As we&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,11],"tags":[],"_links":{"self":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/365"}],"collection":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/comments?post=365"}],"version-history":[{"count":3,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/365\/revisions\/454"}],"wp:attachment":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}