10 Sep 2010 
Support Center » Knowledgebase » Disabling SSH Login for root user
 Disabling SSH Login for root user
Article 1. Add the user. In the following example we will use the user name admin. adduser will automatically create the user, initial group, and home directory.

[root@root ~]# adduser admin
[root@root ~]# id admin
uid=10018(admin) gid=10018(admin) groups=10018(admin)
[root@root ~]# ls -lad /home/admin/
drwx------ 2 admin admin 4096 Jun 25 16:01 /home/admin/

2. Set the password for the admin user. When prompted type and then retype the password.

[root@root ~]# passwd admin
Changing password for user admin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@root ~]#

3. SSH to the server with the new admin user and ensure that the login works.

[root@root ~]#ssh admin@my.ip.or.hostname
admin@my.ip.or.hostname's password:
[admin@admin ~]$

4. Verify that you can su (switch user) to root with the admin user.

[admin@admin ~]$ su -
Password:
[root@root ~]$ whoami
root

5. Edit /etc/ssh/sshd_config with your favorite text editor.


[root@root ~]# vi /etc/ssh/sshd_config

Change this line:


#PermitRootLogin yes

to this:

PermitRootLogin no 

6. Ensure that you are logged into the box with another shell before restarting sshd to avoid locking yourself out of the server.

[root@root ~]# /etc/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[root@root ~]#

You will now be able to ssh into your server with the admin user and then su - to the root user.



Article Details
Article ID: 129
Created On: 11 Jun 2010 2:08 PM

 This article was helpful  This article was not helpful

 Back
 Log in [Lost Password] 
E-mail:
Password:
Remember Me:
 
 Search
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Troubleshooter | News | Downloads
Language:

Helpdesk Software by Kayako SupportSuite v3.50.06