{"id":21,"date":"2009-09-13T17:03:51","date_gmt":"2009-09-13T21:03:51","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=21"},"modified":"2013-03-20T08:39:00","modified_gmt":"2013-03-20T12:39:00","slug":"howto-disable-root-login","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/howto-disable-root-login","title":{"rendered":"Howto: Disable root login on a server?"},"content":{"rendered":"<p><strong>How to disable root login and create an alternate SSH user?<\/strong> In order to disable root access on your server, you need to create an alternate SSH user who have privileges to gain root access else you will be locked out of the system.<\/p>\n<p>First, create a user say\u00a0 &#8216;admin&#8217;<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># useradd admin<\/strong><\/span><\/p><\/blockquote>\n<p>Set a password for the new user<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># passwd admin<\/strong><\/span><\/p><\/blockquote>\n<p>By default, this user will have privileges to su to root but in case of a cPanel server, you need to add the user in the &#8216;wheel&#8217; group.<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>WHM &gt;&gt; Security Center &gt;&gt; &#8220;Manage Wheel Group Users&#8221;<\/strong><\/span><\/p><\/blockquote>\n<p>Once the user is created, follow the steps to disable the root access:<\/p>\n<p>1) Edit the SSHD configuration file &#8216;sshd_config&#8217;:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>pico \/etc\/ssh\/sshd_config<\/strong><\/span><\/p><\/blockquote>\n<p>2) Search the line<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>PermitRootLogin yes<\/strong><\/span><br \/>\nand change it to<br \/>\n<strong> <span style=\"color: #0000ff;\">PermitRootLogin no<\/span><\/strong><\/p><\/blockquote>\n<p>Once you are complete with the above changes, save the file and exit. You will have to restart the sshd service for the changes to take effect.<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>service sshd restart<\/strong><\/span><\/p><\/blockquote>\n<p>Now, you will have to SSH to your server as user &#8216;admin&#8217; and then su to root as follows:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>login as: admin<br \/>\nadmin@xx.xx.xx.xx&#8217;s password: <\/strong><\/span>&lt;admin pass here&gt;<br \/>\n<span style=\"color: #0000ff;\"><strong>[admin@server ~]$ su &#8211;<br \/>\npassword:<\/strong><\/span> &lt;root password here&gt;<br \/>\n<span style=\"color: #0000ff;\"><strong>[root@server ~]#<\/strong><\/span><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>How to disable root login and create an alternate SSH user? In order to disable root access on your server, you need to create an alternate SSH user who have privileges to gain root access else you will be locked out of the system.<br \/>\nFirst, create a user say\u00a0 &#8216;admin&#8217;<br \/>\n# useradd admin<br \/>\nSet a password for the new user<br \/>\n# passwd admin<br \/>\nBy default, this user will have privileges to su to root but in case of a cPanel server, you need to add the user in the &#8216;wheel&#8217; group.<br \/>\nWHM &gt;&gt; Security [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[764,441,436,765],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/21"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":10,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}